Improve error handling to spare the server log from user's malformed requests and stop trying to parse data from providers if the HTTP status was not 200

This commit is contained in:
Ian Renton
2026-07-25 08:17:17 +01:00
parent 34e3933d5d
commit 2fc9658571
26 changed files with 169 additions and 128 deletions
+1 -2
View File
@@ -59,11 +59,10 @@ class APIAlertsHandler(tornado.web.RequestHandler):
self.write(safe_json_dumps(data))
self.set_status(200)
except ValueError as e:
logging.error(e)
self.write(safe_json_dumps("Bad request - " + str(e)))
self.set_status(400)
except Exception as e:
logging.error(e)
logging.error("Exception when handling client request to alerts API: %s", e, exc_info=True)
self.write(safe_json_dumps("Error - an internal server error occurred."))
self.set_status(500)
self.set_header("Cache-Control", "no-store")