Skip to content

Instantly share code, notes, and snippets.

@kgriffs
Forked from anonymous/gist:a69c01c61f6673e12146
Last active August 29, 2015 14:22
Show Gist options
  • Save kgriffs/ff576a54a2a150671f01 to your computer and use it in GitHub Desktop.
Save kgriffs/ff576a54a2a150671f01 to your computer and use it in GitHub Desktop.
Falcon error handling - sample code
# ==================================================
# 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