error-handling: show tracebacks only for error code 500 and above.
This commit is contained in:
parent
e9a7b71fcc
commit
85a3a40913
1 changed files with 8 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue