Skip to content

Instantly share code, notes, and snippets.

@duncangh
Created July 26, 2018 22:44
Show Gist options
  • Save duncangh/6157019a04f4f137e400436877942bd4 to your computer and use it in GitHub Desktop.
Save duncangh/6157019a04f4f137e400436877942bd4 to your computer and use it in GitHub Desktop.
# 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