Last active
April 1, 2016 09:09
-
-
Save timothycrosley/e859291db3d160e104ac to your computer and use it in GitHub Desktop.
Custom Exception handling
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 hug | |
from project import exceptions | |
@hug.exception((exceptions.CustomExceptionTypeOne, exceptions.CustomExceptionTypeTwo)) | |
def handle_custom_exceptions(exception): | |
# handles the passed in custom exception, able to return a different response here: | |
return {'error': 'No error here!'} | |
@hug.exception(Exception) | |
def handle_exception(exception): | |
return {'error': "Python broke again! Don't blame us!"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment