From 12f8be8cda5e877dcd17ea6defea94daf1cb76e1 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 26 Aug 2024 12:58:49 +0300 Subject: Fix handling of sparql errors. * gn3/errors.py (handle_sparql_errors): Use the exception's class name to fetch the status code. Signed-off-by: Munyoki Kilyungi --- gn3/errors.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gn3/errors.py b/gn3/errors.py index 7a97228..e9056d4 100644 --- a/gn3/errors.py +++ b/gn3/errors.py @@ -84,18 +84,16 @@ def handle_sqlite3_errors(exc: OperationalError): def handle_sparql_errors(exc): """Handle sqlite3 errors if not handled anywhere else.""" current_app.logger.error("Handling sparql errors", exc_info=True) - current_app.logger.error(exc) - __code = { - EndPointInternalError: 500, - EndPointNotFound: 400, - QueryBadFormed: 400, - Unauthorized: 401, - URITooLong: 414, + code = { + "EndPointInternalError": 500, + "EndPointNotFound": 404, + "QueryBadFormed": 400, + "Unauthorized": 401, + "URITooLong": 414, } return jsonify({ "error": exc.msg, - "error_description": str(exc), - }), __code.get(exc) + }), code.get(exc.__class__.__name__) def handle_generic(exc: Exception) -> Response: -- cgit v1.2.3