Created
July 26, 2018 22:44
-
-
Save duncangh/6157019a04f4f137e400436877942bd4 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
# Get the name of the exception which occurred as well as the context. | |
try: | |
someFunction() | |
except Exception as ex: | |
template = "An exception of type {0} occurred. Arguments:\n{1!r}" | |
message = template.format(type(ex).__name__, ex.args) | |
print(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see:
https://stackoverflow.com/questions/9823936/python-how-do-i-know-what-type-of-exception-occurred