about summary refs log tree commit diff
path: root/gn3/errors.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/errors.py')
-rw-r--r--gn3/errors.py7
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)