From c7641ef3d115d896ddf07139903b56155a4f888d Mon Sep 17 00:00:00 2001 From: Joern Ungermann Date: Mon, 16 Sep 2024 12:42:54 +0200 Subject: [PATCH] Handle Exceptions at the outer level, so no unforeseen errors occur. --- mslib/msui/mscolab.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mslib/msui/mscolab.py b/mslib/msui/mscolab.py index e018ebafe..162f3715f 100644 --- a/mslib/msui/mscolab.py +++ b/mslib/msui/mscolab.py @@ -77,9 +77,16 @@ class MSColabConnectionError(RuntimeError): pass +__verify_user_token_depth = 0 + + def verify_user_token(func): + @functools.wraps(func) def wrapper(*args, **vargs): + global __verify_user_token_depth + __verify_user_token_depth += 1 + self = args[0] if self.mscolab_server_url is None: # in case of a forecd logout some QT events may still trigger MSCOLAB functions @@ -87,11 +94,17 @@ def wrapper(*args, **vargs): try: if not _verify_user_token(self.mscolab_server_url, self.token): raise MSColabConnectionError("Your Connection is expired. New Login required!") - return func(*args, **vargs) + assert self.mscolab_server_url is not None + result = func(*args, **vargs) + return result except MSColabConnectionError as ex: + if __verify_user_token_depth > 1: + raise logging.error("%s", ex) show_popup(self.ui, "Error", str(ex)) self.logout() + finally: + __verify_user_token_depth -= 1 return wrapper