In some exception handling code, I'd like to perform an emergency shutdown operation and then re-raise the exception. I am using an asynchronous programming model (Twisted), and I would like to re-raise the exception in the emergency shutdown's callback.
I'd like to do something like this:
except Exception as e:
d = emergencyStop()
d.addCallback(partial(raiseExn, e))
I could define my own raiseExn
function:
def raiseExn(e):
raise e
But it seems silly to add three or four lines to every place I want to use this code. I expect that the raise
keyword probably calls a function somewhere in the Python standard library and it would be better to use that. But what is that function?