-
-
Save kgriffs/ff576a54a2a150671f01 to your computer and use it in GitHub Desktop.
Falcon error handling - sample code
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
# ================================================== | |
# If an error is raised while loading the module, | |
# and it isn't handled (or it is re-raised), it | |
# will go straight to the WSGI server. | |
# ================================================== | |
model = Model() | |
try: | |
model.load() | |
except Exception as ex: | |
# Handle the error here - log and re-raise to the | |
# WSGI server, retry, or whatever... | |
pass | |
resource = Resource(model) | |
api = falcon.API() | |
api.add_route('/foo', resource) | |
# ================================================== | |
# At this point the module has been parsed and | |
# loaded by the WSGI server. Future errors raised | |
# inside your app will go through Falcon's error | |
# handling logic. | |
# ================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment