I was quite frustrated debugging my callbacks mainly because I saw only the error message but python didn’t tell me in which line the exception occurred.
There might be an easier way but I found a workaround. Wrap your callback in a try-catch-block like this:
def my_callback():
try:
...normal code...
except Exception as e:
import traceback
traceback.print_exc()
raise e
In this way, the stack trace will be printed and the exception is forwarded as usual. Hope it helps somebody.
On Wednesday, August 30, 2017 at 7:52:32 AM UTC-4, Colin wrote:
I was quite frustrated debugging my callbacks mainly because I saw only the error message but python didn’t tell me in which line the exception occurred.
There might be an easier way but I found a workaround. Wrap your callback in a try-catch-block like this:
def my_callback():
try:
...normal code...
except Exception as e:
import traceback
traceback.print_exc()
raise e
In this way, the stack trace will be printed and the exception is forwarded as usual. Hope it helps somebody.
Perhaps we could add something like that built in. In general, putting things in try/except blocks will incur performance overhead, so I would not want to have it on by default, but it might make sense as an optional debugging more. Please feel free to open a GH issue to discuss.
On Wednesday, August 30, 2017 at 7:52:32 AM UTC-4, Colin wrote:
I was quite frustrated debugging my callbacks mainly because I saw only the error message but python didn't tell me in which line the exception occurred.
There might be an easier way but I found a workaround. Wrap your callback in a try-catch-block like this:
def my_callback():
try:
...normal code...
except Exception as e:
import traceback
traceback.print_exc()
raise e
In this way, the stack trace will be printed and the exception is forwarded as usual. Hope it helps somebody.