Skip to content

Commit

Permalink
Handle Exceptions at the outer level, so no unforeseen errors occur.
Browse files Browse the repository at this point in the history
  • Loading branch information
joernu76 committed Sep 16, 2024
1 parent a064e91 commit c7641ef
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,34 @@ 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
return
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


Expand Down

0 comments on commit c7641ef

Please sign in to comment.