Just an idea, nothing I have tested. And maybe not working as I hope it would:
Try LibDebugLogger and DebugLogViewer with the same code.
Enable in the addon settings of DebugLogViewer -> LibDebugLogger submenu -> Stack traceback.
Test if the error message shown in the DebugLogViewer UI will show the traceback stack (if clicked) up to your "if" function line in your code.
|