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:
Leo Hemsted
2018-03-08 16:10:17 +00:00
parent 1cd8000236
commit 29ae0118f3

View File

@@ -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)