error-handling: show tracebacks only for error code 500 and above.

This commit is contained in:
Marcin Kuzminski 2017-01-13 11:27:38 +01:00
parent e9a7b71fcc
commit 85a3a40913

View file

@ -227,13 +227,19 @@ def error_handler(exception, request):
log.exception('failed to fetch settings')
rc_config = {}
log.exception(
'error occurred handling this request for path: %s', request.path)
base_response = HTTPInternalServerError()
# prefer original exception for the response since it may have headers set
if isinstance(exception, HTTPError):
base_response = exception
def is_http_error(response):
# error which should have traceback
return response.status_code > 499
if is_http_error(base_response):
log.exception(
'error occurred handling this request for path: %s', request.path)
c = AttributeDict()
c.error_message = base_response.status
c.error_explanation = base_response.explanation or str(base_response)