From 75aaa03b9262b2e9dcbc9f7f9c4a163c2acdac04 Mon Sep 17 00:00:00 2001 From: josephine-rutten Date: Mon, 5 Feb 2024 14:18:40 +0100 Subject: [PATCH] last change based on sonarcloud --- src/cnaas_nms/api/app.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cnaas_nms/api/app.py b/src/cnaas_nms/api/app.py index db655fe6..a9ea1b19 100644 --- a/src/cnaas_nms/api/app.py +++ b/src/cnaas_nms/api/app.py @@ -88,15 +88,14 @@ def handle_error(self, e): elif isinstance(e, InvalidSignatureError): data = {"status": "error", "message": "Invalid token signature"} return jsonify(data), 401 - elif isinstance(e, IndexError): - # We might catch IndexErrors which are not caused by JWT, - # but this is better than nothing. - data = {"status": "error", "message": "JWT token missing?"} - return jsonify(data), 401 elif isinstance(e, InvalidHeaderError): data = {"status": "error", "message": "Invalid header, JWT token missing? {}".format(e)} return jsonify(data), 401 - elif isinstance(e, MissingAuthorizationError) or isinstance(e, NoAuthorizationError): + elif ( + isinstance(e, MissingAuthorizationError) or isinstance(e, NoAuthorizationError) or isinstance(e, IndexError) + ): + # We might catch IndexErrors which are not caused by JWT, + # but this is better than nothing. data = {"status": "error", "message": "JWT token missing?"} return jsonify(data), 401 elif isinstance(e, ConnectionError):