diff options
author | genofire <geno+dev@fireorbit.de> | 2020-07-19 22:34:11 +0200 |
---|---|---|
committer | genofire <geno+dev@fireorbit.de> | 2020-07-19 22:42:05 +0200 |
commit | 0befdb44c27075c991515bbe50f53454fc5bc183 (patch) | |
tree | 5d06c113be17135aed1dff385e0ba791c21c2db2 | |
parent | 091b6e525aacad1abf8d800338d242141dec11c2 (diff) |
exception handling
-rwxr-xr-x | cleanup.py | 6 | ||||
-rwxr-xr-x | prometheus.py | 4 |
2 files changed, 5 insertions, 5 deletions
@@ -38,11 +38,11 @@ class EjabberdCleanup(EjabberdApiCalls): lastdate = None try: lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%SZ") - except: # noqa: E722 + except ValueError: try: lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%S.%fZ") - except: # noqa: E722 - logging.error(f"{user}@{host}: not able to parse '{last_stamp}'") + except ValueError as err: + logging.error(f"{user}@{host}: not able to parse '{last_stamp}': {err}") return if lastdate is not None and lastdate - datetime.datetime.now() > datetime.timedelta( days=self.offline_since_days diff --git a/prometheus.py b/prometheus.py index a526851..676b6fc 100755 --- a/prometheus.py +++ b/prometheus.py @@ -23,8 +23,8 @@ class DynamicMetricsHandler(BaseHTTPRequestHandler): registry = registry.restricted_registry(params["name[]"]) try: output = generate_latest(registry) - except: # noqa: E722 - self.send_error(500, "error generating metric output") + except Exception as exception: + self.send_error(500, f"error generating metric output: {exception}") raise self.send_response(200) self.send_header("Content-Type", CONTENT_TYPE_LATEST) |