For example:
class ExceptionMeta(type):
def __call__(cls, *args, **kwargs):
if exception_raised_from_try_block:
do_something
else:
do_something_else
class TimeOutError(metaclass = ExceptionMeta):
pass
try:
raise TimeOutError
except Exception as e:
pass
The actual problem is that I have a code block in which I am having a TimeOut error in the try - except block. Every time a TimeOut error is raised, I catch it in try - except block and issue retry for 5 times. This TimeOut error has an object which will collect the error traces in case the exception is raised so as to provide more context while debugging the issue. But every time the exception is raised in the try block, the call goes to call function and it ends up collecting the traces for that error which I dont want as I am just retrying again in the except block
Is there any way in python using inspection or some other module which can tell me that exception was raised from a try block?
tryblock and another behavior if uncaught, but they are only a signal - exceptions should not have side effects.