I have a dict like this:
{
"stackTrace": [
["/path/to/some/code.py", 10, "some_function", "do_something()"],
["/path/to/some/code.py", 20, "do_something", "raise MyException('aaaa')"]
],
"errorType": "MyException",
"errorMessage": "aaaa",
}
I can make it pretty with traceback.format_list
but I was wondering if there was a way to reconstruct the actual exception and raise it. I figure I can dynamically create the exception type and use the same message but how can I preserve the stack trace?
edit: so, I've tried this, but I'm stuck on turning the stackTrace
in my dict into a traceback
object. I've no idea how to do it - apparently it is very difficult to do so I'm wondering if there's a different way to accomplish what I want.
raise type(mydict['errorType'], (Exception,), {}), mydict['errorMessage'], traceback???