diff options
author | Frederick Muriuki Muriithi | 2023-10-19 09:03:52 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-10-19 09:10:00 +0300 |
commit | 6e16566c0bfb81561104f4db6934b6d216ed4fe7 (patch) | |
tree | 18f2f194df15e67794bfa17bea931504284ef92e /gn3 | |
parent | 0a7c9c8f5a329321f4bac9bcabaa160b5f6b12aa (diff) | |
download | genenetwork3-6e16566c0bfb81561104f4db6934b6d216ed4fe7.tar.gz |
Handle 404 error(s) at top level.
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/errors.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gn3/errors.py b/gn3/errors.py index f9b3c02..121187c 100644 --- a/gn3/errors.py +++ b/gn3/errors.py @@ -5,6 +5,12 @@ from authlib.oauth2.rfc6749.errors import OAuth2Error from gn3.auth.authorisation.errors import AuthorisationError +def page_not_found(pnf): + return jsonify({ + "error": pnf.name, + "error_description": pnf.description + }), 404 + def handle_authorisation_error(exc: AuthorisationError): """Handle AuthorisationError if not handled anywhere else.""" current_app.logger.error(exc) @@ -31,6 +37,7 @@ def handle_sqlite3_errors(exc: OperationalError): def register_error_handlers(app: Flask): """Register application-level error handlers.""" + app.register_error_handler(404, page_not_found) app.register_error_handler(OAuth2Error, handle_oauth2_errors) app.register_error_handler(OperationalError, handle_sqlite3_errors) app.register_error_handler(AuthorisationError, handle_authorisation_error) |