Skip to content

Instantly share code, notes, and snippets.

@dtoma
Created December 29, 2019 07:16
Show Gist options
  • Save dtoma/fe6eea1327705c24c35086a73924d26d to your computer and use it in GitHub Desktop.
Save dtoma/fe6eea1327705c24c35086a73924d26d to your computer and use it in GitHub Desktop.
Python exception handling
# https://speakerdeck.com/pycon2019/mario-corchero-how-to-properly-raise-handle-and-create-them?slide=50
try:
# ...
exception (KeyError, ValueError):
logging.info('Attempted to call x with invalid input', exc_info=True)
raise InvalidDataCustomError('Invalid data used to call X') from None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment