I am trying to override sys.excepthook
exception handling. However, it simply not works.
This is the code I am running.
from sys import excepthook
excepthook = lambda type, exception, traceback : print('foo')
raise Exception('bar')
The following code calls my overriden method:
from sys import excepthook
excepthook = lambda type, exception, traceback : print('foo')
try:
raise Exception('bar')
except Exception as e:
excepthook(Exception, e, e._traceback_)
This code is useless due to the fact sys.excepthook
should catch unhandled exceptions.
I`m aware many people is having issues such as mine, however, none of the issues helped me solve my problem.
why-doesnt-sys-excepthook-work
adding-function-to-sys-excepthook
sys-excepthook-vs-handled-exceptions
Thanks.