##// END OF EJS Templates
vcs: Use response header to decide if error handling is needed.
Martin Bornhold -
r609:24f4767a default
parent child Browse files
Show More
@@ -200,19 +200,21 b' def make_not_found_view(config):'
200 - old webob type exceptions get converted to pyramid exceptions
200 - old webob type exceptions get converted to pyramid exceptions
201 - pyramid exceptions are passed to the error handler view
201 - pyramid exceptions are passed to the error handler view
202 """
202 """
203 def is_vcs_request(request):
203 def is_vcs_response(response):
204 return True == request.environ.get(
204 return 'X-RhodeCode-Backend' in response.headers
205 'rhodecode.vcs.skip_error_handling')
206
205
207 def is_webob_error(response):
206 def is_http_error(response):
208 # webob type error responses
207 # webob type error responses
209 return (400 <= response.status_int <= 599)
208 return (400 <= response.status_int <= 599)
210
209
210 def is_error_handling_needed(response):
211 return is_http_error(response) and not is_vcs_response(response)
212
211 try:
213 try:
212 response = pylons_app_as_view(context, request)
214 response = pylons_app_as_view(context, request)
213 if is_webob_error(response) and not is_vcs_request(request):
215 if is_error_handling_needed(response):
214 return error_handler(
216 response = webob_to_pyramid_http_response(response)
215 webob_to_pyramid_http_response(response), request)
217 return error_handler(response, request)
216 except HTTPError as e: # pyramid type exceptions
218 except HTTPError as e: # pyramid type exceptions
217 return error_handler(e, request)
219 return error_handler(e, request)
218 except Exception:
220 except Exception:
General Comments 0
You need to be logged in to leave comments. Login now