I have a retry-mechanism in my python code. I want to raise an exception if all tries failed somehow
something like this:
last_exc = None
for i in range(3):
    try:
        raise Exception(i)
    except Exception as e:
        last_exc = e        
else:
    raise last_exc
But the issue is that I do not get the exact traceback in the logs. I just get the following message:
Traceback (most recent call last):
  File "snippet.py", line 8, in <module>
    raise e
Exception: 2
I was expecting raise Exception(i) (line:4) as the traceback in the exception. the behaviour is only with python 2.7.
How can I set the exact traceback of the exception I am raising, which was raised in the last exception?
 
    