From a54b212bc3a64ca364d1f2e3245ffdab71c9ee93 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 19 Apr 2023 16:16:28 +0300 Subject: oauth2: fix bug with error handling. --- wqflask/wqflask/oauth2/request_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/oauth2/request_utils.py b/wqflask/wqflask/oauth2/request_utils.py index fae3a347..0cd1697b 100644 --- a/wqflask/wqflask/oauth2/request_utils.py +++ b/wqflask/wqflask/oauth2/request_utils.py @@ -1,6 +1,7 @@ """General request utilities""" from typing import Optional +import simplejson from flask import ( flash, session, url_for, redirect, Response, render_template, current_app as app) @@ -20,7 +21,10 @@ def process_error(error: Response, "server.") ) -> dict: if error.status_code == 404: - msg = error.json()["error_description"] if hasattr(error, "json") else message + try: + msg = error.json()["error_description"] + except simplejson.errors.JSONDecodeError as _jde: + msg = message return { "error": "NotFoundError", "error_message": msg, -- cgit v1.2.3