From 570410a0e8a18099a53f412c0016962d7607ab71 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 6 Sep 2024 10:45:41 -0500 Subject: Fail noisily to help with troubleshooting issues. --- gn2/wqflask/oauth2/request_utils.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/oauth2/request_utils.py b/gn2/wqflask/oauth2/request_utils.py index 456aba2b..167d0cbd 100644 --- a/gn2/wqflask/oauth2/request_utils.py +++ b/gn2/wqflask/oauth2/request_utils.py @@ -24,9 +24,15 @@ def authserver_authorise_uri(): def user_details(): - return oauth2_get("auth/user/").either( - lambda err: {}, - lambda usr_dets: usr_dets) + def __handle_error__(err): + error = process_error(err) + msg = ( + f"Error from AUTH Server:\n\nError:\t{error['error']}\n\n" + f"{error['error-trace']}\nStatus Code:\t{error['status_code']}\n\n") + app.logger.error(msg) + raise Exception(msg) + return oauth2_get("auth/user/").either(__handle_error__, + lambda usr_dets: usr_dets) def process_error(error: Response, message: str=("Requested endpoint was not found on the API " -- cgit v1.2.3