Created
March 16, 2017 11:34
-
-
Save pkoch/b870f60940864875575927f11852946a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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