# HG changeset patch # User Marcin Kuzminski # Date 2017-01-13 10:27:38 # Node ID 456979480cb63f3f7699003f688fb75f4df8467d # Parent 8df63e5b4433e67d1eac13d4fe781643233a2b98 error-handling: show tracebacks only for error code 500 and above. diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -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)