From 29ae0118f3521446c2f23f580a9aab68ea76a135 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 8 Mar 2018 16:10:17 +0000 Subject: [PATCH] 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. --- app/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index de4c0a949..702081e38 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -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)