Created
January 2, 2013 13:55
-
-
Save rantav/4434741 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
import traceback | |
try: | |
5 / 0 | |
except ZeroDivisionError, e: | |
print e | |
# this will just print "integer division or modulo by zero" | |
# but if you try this: | |
exception_type, exception_value, exception_traceback = sys.exc_info() | |
print "Traceback: %s" % traceback.format_tb(exception_traceback) | |
print "value: %s" % exception_value | |
print "type: %s" % exception_type | |
# This will print: | |
# | |
# Traceback: [' File "tmp.py", line 4, in <module>\n 5 / 0\n'] | |
# value: integer division or modulo by zero | |
# type: <type 'exceptions.ZeroDivisionError'> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment