##// 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 211 return {'status': '404 NOT FOUND'}
212 212 self.config.add_notfound_view(notfound, renderer='json')
213 213
214 self.config.add_view(
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)
214 self.config.add_view(self.handle_vcs_exception, context=Exception)
220 215
221 216 self.config.add_tween(
222 217 'vcsserver.tweens.RequestWrapperTween',
@@ -380,27 +375,17 b' class HTTPApplication(object):'
380 375 backend = request.matchdict.get('backend')
381 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 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 381 # Get custom repo-locked status code if present.
393 382 status_code = request.headers.get('X-RC-Locked-Status-Code')
394 383 return HTTPRepoLocked(
395 384 title=exception.message, status_code=status_code)
396 385
397 386 # Re-raise exception if we can not handle it.
398 raise exception
399
400 def general_error_handler(self, exception, request):
401 387 log.exception(
402 'error occurred handling this request for path: %s',
403 request.path)
388 'error occurred handling this request for path: %s', request.path)
404 389 raise exception
405 390
406 391
General Comments 0
You need to be logged in to leave comments. Login now