Merge branch 'exception' into 'master'
Bare exception handling Closes #4 and #5 See merge request sum7/ejabberd-tools!7
This commit is contained in:
commit
bf49087072
|
@ -38,11 +38,11 @@ class EjabberdCleanup(EjabberdApiCalls):
|
||||||
lastdate = None
|
lastdate = None
|
||||||
try:
|
try:
|
||||||
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%SZ")
|
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
except: # noqa: E722
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%S.%fZ")
|
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||||
except: # noqa: E722
|
except ValueError as err:
|
||||||
logging.error(f"{user}@{host}: not able to parse '{last_stamp}'")
|
logging.error(f"{user}@{host}: not able to parse '{last_stamp}': {err}")
|
||||||
return
|
return
|
||||||
if lastdate is not None and lastdate - datetime.datetime.now() > datetime.timedelta(
|
if lastdate is not None and lastdate - datetime.datetime.now() > datetime.timedelta(
|
||||||
days=self.offline_since_days
|
days=self.offline_since_days
|
||||||
|
|
|
@ -23,8 +23,8 @@ class DynamicMetricsHandler(BaseHTTPRequestHandler):
|
||||||
registry = registry.restricted_registry(params["name[]"])
|
registry = registry.restricted_registry(params["name[]"])
|
||||||
try:
|
try:
|
||||||
output = generate_latest(registry)
|
output = generate_latest(registry)
|
||||||
except: # noqa: E722
|
except Exception as exception:
|
||||||
self.send_error(500, "error generating metric output")
|
self.send_error(500, f"error generating metric output: {exception}")
|
||||||
raise
|
raise
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header("Content-Type", CONTENT_TYPE_LATEST)
|
self.send_header("Content-Type", CONTENT_TYPE_LATEST)
|
||||||
|
|
Loading…
Reference in New Issue