about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-06-17 14:29:04 -0500
committerFrederick Muriuki Muriithi2024-06-17 14:29:04 -0500
commitfc1c34201fe6d905d7bea9ec19cd7ae59af48e0c (patch)
tree70a9dea5eee8ac132bb765517b75aab725dc63fb
parent4b0eed1a90a200a4283778b10d116f4f76ad9455 (diff)
downloadgn-auth-fc1c34201fe6d905d7bea9ec19cd7ae59af48e0c.tar.gz
Improve error-handling.
-rw-r--r--gn_auth/errors.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/gn_auth/errors.py b/gn_auth/errors.py
index df3aa86..1b6bc81 100644
--- a/gn_auth/errors.py
+++ b/gn_auth/errors.py
@@ -8,7 +8,9 @@ from gn_auth.auth.errors import AuthorisationError
 
 def add_trace(exc: Exception, errobj: dict) -> dict:
     """Add the traceback to the error handling object."""
-    current_app.logger.debug(traceback.format_exception(exc))
+    current_app.logger.debug("Endpoint: %s\n%s",
+                             request.url,
+                             traceback.format_exception(exc))
     return {
         **errobj,
         "error-trace": "".join(traceback.format_exception(exc))
@@ -28,10 +30,11 @@ def page_not_found(exc):
 
 
 def handle_general_exception(exc: Exception):
+    """Handle generic unhandled exceptions."""
     content_type = request.content_type
     if bool(content_type) and content_type.lower() == "application/json":
         msg = ("The following exception was raised while attempting to access "
-               f"{request.url}: {exc.args[0]}")
+               f"{request.url}: {' '.join(exc.args)}")
         return jsonify(add_trace(exc, {
             "error": type(exc).__name__,
             "error_description": msg