handle auth exception

This commit is contained in:
əlemi 2022-04-19 00:23:56 +02:00
parent 280d97afc8
commit 9d7badba5d
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -149,9 +149,9 @@ class Treepuncher(
prev = self.storage.system() # if this isn't 1st time, this won't be None. Load token from there prev = self.storage.system() # if this isn't 1st time, this won't be None. Load token from there
if prev: if prev:
if self.name != prev.name: if self.name != prev.name:
self.logger.warning("Saved credentials belong to another session") self.logger.warning("Saved session belong to another user")
authenticator.deserialize(json.loads(prev.token)) authenticator.deserialize(json.loads(prev.token))
self.logger.info("Loaded credentials") self.logger.info("Loaded authenticated session")
self.modules = [] self.modules = []
@ -221,6 +221,9 @@ class Treepuncher(
self.logger.error("Server rejected connection") self.logger.error("Server rejected connection")
except OSError as e: except OSError as e:
self.logger.error("Connection error : %s", str(e)) self.logger.error("Connection error : %s", str(e))
except AuthException as e:
self.logger.error("Auth exception : [%s|%d] %s (%s)", e.endpoint, e.code, e.data, e.kwargs)
break
except Exception: except Exception:
self.logger.exception("Unhandled exception") self.logger.exception("Unhandled exception")
break break