##// END OF EJS Templates
exceptions: use only one exception handler to track errors with nicer...
marcink -
r178:f5cbb023 default
parent child Browse files
Show More
@@ -211,12 +211,7 b' class HTTPApplication(object):'
211 return {'status': '404 NOT FOUND'}
211 return {'status': '404 NOT FOUND'}
212 self.config.add_notfound_view(notfound, renderer='json')
212 self.config.add_notfound_view(notfound, renderer='json')
213
213
214 self.config.add_view(
214 self.config.add_view(self.handle_vcs_exception, context=Exception)
215 self.handle_vcs_exception, context=Exception,
216 custom_predicates=[self.is_vcs_exception])
217
218 self.config.add_view(
219 self.general_error_handler, context=Exception)
220
215
221 self.config.add_tween(
216 self.config.add_tween(
222 'vcsserver.tweens.RequestWrapperTween',
217 'vcsserver.tweens.RequestWrapperTween',
@@ -380,27 +375,17 b' class HTTPApplication(object):'
380 backend = request.matchdict.get('backend')
375 backend = request.matchdict.get('backend')
381 return backend in self._remotes
376 return backend in self._remotes
382
377
383 def is_vcs_exception(self, context, request):
384 """
385 View predicate that returns true if the context object is a VCS
386 exception.
387 """
388 return hasattr(context, '_vcs_kind')
389
390 def handle_vcs_exception(self, exception, request):
378 def handle_vcs_exception(self, exception, request):
391 if exception._vcs_kind == 'repo_locked':
379 _vcs_kind = getattr(exception, '_vcs_kind', '')
380 if _vcs_kind == 'repo_locked':
392 # Get custom repo-locked status code if present.
381 # Get custom repo-locked status code if present.
393 status_code = request.headers.get('X-RC-Locked-Status-Code')
382 status_code = request.headers.get('X-RC-Locked-Status-Code')
394 return HTTPRepoLocked(
383 return HTTPRepoLocked(
395 title=exception.message, status_code=status_code)
384 title=exception.message, status_code=status_code)
396
385
397 # Re-raise exception if we can not handle it.
386 # Re-raise exception if we can not handle it.
398 raise exception
399
400 def general_error_handler(self, exception, request):
401 log.exception(
387 log.exception(
402 'error occurred handling this request for path: %s',
388 'error occurred handling this request for path: %s', request.path)
403 request.path)
404 raise exception
389 raise exception
405
390
406
391
General Comments 0
You need to be logged in to leave comments. Login now