From 9d7badba5def8317fa72aa0a426b05cac37357b4 Mon Sep 17 00:00:00 2001 From: alemidev Date: Tue, 19 Apr 2022 00:23:56 +0200 Subject: [PATCH] handle auth exception --- src/treepuncher/treepuncher.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/treepuncher/treepuncher.py b/src/treepuncher/treepuncher.py index a889791..ebc3dab 100644 --- a/src/treepuncher/treepuncher.py +++ b/src/treepuncher/treepuncher.py @@ -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 if prev: 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)) - self.logger.info("Loaded credentials") + self.logger.info("Loaded authenticated session") self.modules = [] @@ -221,6 +221,9 @@ class Treepuncher( self.logger.error("Server rejected connection") except OSError as 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: self.logger.exception("Unhandled exception") break