to abitrary responses. Anything returned (except None) will
be used as response."""
self._failed = exception # prevent tx commit
- if isinstance(exception, werkzeug.exceptions.HTTPException):
- return exception
raise
def _call_function(self, *args, **kwargs):
params.pop('session_id', None)
self.params = params
+ def _handle_exception(self, exception):
+ """Called within an except block to allow converting exceptions
+ to abitrary responses. Anything returned (except None) will
+ be used as response."""
+ try:
+ return super(HttpRequest, self)._handle_exception(exception)
+ except werkzeug.exceptions.HTTPException, e:
+ return e
+
def dispatch(self):
if request.httprequest.method == 'OPTIONS' and request.endpoint and request.endpoint.routing.get('cors'):
headers = {
request = self.get_request(httprequest)
def _dispatch_nodb():
- func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()
+ try:
+ func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()
+ except werkzeug.exceptions.HTTPException, e:
+ return request._handle_exception(e)
request.set_handler(func, arguments, "none")
result = request.dispatch()
return result