mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 19:03:30 -05:00
log as exception if the api returns 5xx
if it returns 400 only log warning, as they're much less urgent. it's probably someone clicking an old invite or something.
This commit is contained in:
@@ -488,7 +488,7 @@ def register_errorhandlers(application): # noqa (C901 too complex)
|
||||
|
||||
@application.errorhandler(HTTPError)
|
||||
def render_http_error(error):
|
||||
application.logger.error("API {} failed with status {} message {}".format(
|
||||
application.logger.warning("API {} failed with status {} message {}".format(
|
||||
error.response.url if error.response else 'unknown',
|
||||
error.status_code,
|
||||
error.message
|
||||
@@ -501,7 +501,13 @@ def register_errorhandlers(application): # noqa (C901 too complex)
|
||||
msg = list(itertools.chain(*[error.message[x] for x in error.message.keys()]))
|
||||
resp = make_response(render_template("error/400.html", message=msg))
|
||||
return useful_headers_after_request(resp)
|
||||
elif error_code not in [401, 404, 403, 410, 500]:
|
||||
elif error_code not in [401, 404, 403, 410]:
|
||||
# probably a 500 or 503
|
||||
application.logger.exception("API {} failed with status {} message {}".format(
|
||||
error.response.url if error.response else 'unknown',
|
||||
error.status_code,
|
||||
error.message
|
||||
))
|
||||
error_code = 500
|
||||
return _error_response(error_code)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user