about summary refs log tree commit diff
path: root/gn_auth/errors
diff options
context:
space:
mode:
Diffstat (limited to 'gn_auth/errors')
-rw-r--r--gn_auth/errors/authlib.py2
-rw-r--r--gn_auth/errors/common.py5
2 files changed, 4 insertions, 3 deletions
diff --git a/gn_auth/errors/authlib.py b/gn_auth/errors/authlib.py
index 09862e3..c85b67c 100644
--- a/gn_auth/errors/authlib.py
+++ b/gn_auth/errors/authlib.py
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
 
 def __description__(body):
     """Improve description for errors in authlib.oauth2.rfc6749.errors"""
-    _desc = body["error_description"]
+    _desc = body.get("error_description", body["error"])
     match body["error"]:
         case "missing_authorization":
             return (
diff --git a/gn_auth/errors/common.py b/gn_auth/errors/common.py
index 8dc0373..35e4d21 100644
--- a/gn_auth/errors/common.py
+++ b/gn_auth/errors/common.py
@@ -30,10 +30,11 @@ def build_handler(description: str) -> Callable[[Exception], Response]:
     """Generic utility to build error handlers."""
     def __handler__(exc: Exception) -> Response:
         """Handle the exception as appropriate for requests of different mimetypes."""
+        logger.debug("EXCEPTION: %s", exc, exc_info=True)
         error = (exc.name if hasattr(exc, "name") else exc.__class__.__name__)
         status_code = __status_code__(exc)
-        content_type = request.content_type
-        if bool(content_type) and content_type.lower() == "application/json":
+        if ("application/json" in request.headers.get("Accept", "")
+            or "application/json" in request.headers.get("Content-Type", "")):
             return make_response((
                 add_trace(
                     exc,