Skip to content

Instantly share code, notes, and snippets.

@pkoch
Created March 16, 2017 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkoch/b870f60940864875575927f11852946a to your computer and use it in GitHub Desktop.
Save pkoch/b870f60940864875575927f11852946a to your computer and use it in GitHub Desktop.
import sys
INSTRUCTIONS = "You might want to derp"
def b():
raise Exception("So far away, we wait for the day ")
def a():
b()
def deep_exploder():
a()
def reraiser(cls, new_message, tb):
if sys.version_info[0] < 3:
exec("raise cls, new_message, tb") # It's a syntax error on py3 :(
raise cls(new_message). with_traceback(tb)
def main():
try:
return deep_exploder()
except Exception as e:
new_message = "\n".join([str(e), INSTRUCTIONS])
cls, _, tb = sys.exc_info()
reraiser(cls, new_message, tb)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment