Skip to content

Commit

Permalink
last change based on sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Josephine-Rutten committed Feb 5, 2024
1 parent 3d6d5d8 commit 75aaa03
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/cnaas_nms/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 75aaa03

Please sign in to comment.