logging: exceptions can log more info

This commit is contained in:
alfrix
2022-05-14 17:04:50 -03:00
committed by Alfredo Monclus
parent 7c8d4ea4d7
commit 562e49b8d2
4 changed files with 15 additions and 8 deletions

View File

@@ -34,7 +34,8 @@ class KlippyRest:
headers = {} if self.api_key is False else {"x-api-key": self.api_key}
try:
r = requests.get(url, headers=headers)
except Exception:
except Exception as e:
logging.critical(e, exc_info=True)
return False
if r.status_code != 200:
return False
@@ -42,7 +43,8 @@ class KlippyRest:
# TODO: Try/except
try:
data = json.loads(r.content)
except Exception:
except Exception as e:
logging.critical(e, exc_info=True)
logging.exception("Unable to parse response from moonraker:\n %s" % r.content)
return False