Created
March 16, 2017 11:29
-
-
Save pkoch/546f6c0f6887722b8f97a06f9400576b 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 main(): | |
try: | |
return deep_exploder() | |
except Exception as e: | |
new_message = "\n".join([str(e), INSTRUCTIONS]) | |
cls, _, tb = sys.exc_info() | |
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) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment