Method: flask.app.Flask.handle_http_exception
Calls: 70, Exceptions: 0, Paths: 4Back
Path 1: 35 calls (0.5)
Forbidden (16) InternalServerError (9) NotFound (6) test_http_error_subclass_handling.
'direct InternalServerError' (5) 'forbidden' (3) 'apple' (2) ('you shall not pass', 403) (2) ('Parent no', 403) (2) ('Error', 403) (2) ('not found', 4...
1def handle_http_exception(
2 self, e: HTTPException
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """Handles an HTTP exception. By default this will invoke the
5 registered error handlers and fall back to returning the
6 exception as response.
7
8 .. versionchanged:: 1.0.3
9 ``RoutingException``, used internally for actions such as
10 slash redirects during routing, is not passed to error
11 handlers.
12
13 .. versionchanged:: 1.0
14 Exceptions are looked up by code *and* by MRO, so
15 ``HTTPException`` subclasses can be handled with a catch-all
16 handler for the base ``HTTPException``.
17
18 .. versionadded:: 0.3
19 """
20 # Proxy exceptions don't have error codes. We want to always return
21 # those unchanged as errors
22 if e.code is None:
23 return e
24
25 # RoutingExceptions are used internally to trigger routing
26 # actions, such as slash redirects raising RequestRedirect. They
27 # are not raised or handled in user code.
28 if isinstance(e, RoutingException):
29 return e
30
31 handler = self._find_error_handler(e)
32 if handler is None:
33 return e
34 return self.ensure_sync(handler)(e)
Path 2: 32 calls (0.46)
MethodNotAllowed (15) NotFound (10) BadRequest (5) BadRequestKeyError (1) BadHost (1)
MethodNotAllowed (15) NotFound (10) BadRequest (5) BadRequestKeyError (1) BadHost (1)
1def handle_http_exception(
2 self, e: HTTPException
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """Handles an HTTP exception. By default this will invoke the
5 registered error handlers and fall back to returning the
6 exception as response.
7
8 .. versionchanged:: 1.0.3
9 ``RoutingException``, used internally for actions such as
10 slash redirects during routing, is not passed to error
11 handlers.
12
13 .. versionchanged:: 1.0
14 Exceptions are looked up by code *and* by MRO, so
15 ``HTTPException`` subclasses can be handled with a catch-all
16 handler for the base ``HTTPException``.
17
18 .. versionadded:: 0.3
19 """
20 # Proxy exceptions don't have error codes. We want to always return
21 # those unchanged as errors
22 if e.code is None:
23 return e
24
25 # RoutingExceptions are used internally to trigger routing
26 # actions, such as slash redirects raising RequestRedirect. They
27 # are not raised or handled in user code.
28 if isinstance(e, RoutingException):
29 return e
30
31 handler = self._find_error_handler(e)
32 if handler is None:
33 return e
34 return self.ensure_sync(handler)(e)
Path 3: 2 calls (0.03)
RequestRedirect (2)
RequestRedirect (2)
1def handle_http_exception(
2 self, e: HTTPException
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """Handles an HTTP exception. By default this will invoke the
5 registered error handlers and fall back to returning the
6 exception as response.
7
8 .. versionchanged:: 1.0.3
9 ``RoutingException``, used internally for actions such as
10 slash redirects during routing, is not passed to error
11 handlers.
12
13 .. versionchanged:: 1.0
14 Exceptions are looked up by code *and* by MRO, so
15 ``HTTPException`` subclasses can be handled with a catch-all
16 handler for the base ``HTTPException``.
17
18 .. versionadded:: 0.3
19 """
20 # Proxy exceptions don't have error codes. We want to always return
21 # those unchanged as errors
22 if e.code is None:
23 return e
24
25 # RoutingExceptions are used internally to trigger routing
26 # actions, such as slash redirects raising RequestRedirect. They
27 # are not raised or handled in user code.
28 if isinstance(e, RoutingException):
29 return e
30
31 handler = self._find_error_handler(e)
32 if handler is None:
33 return e
34 return self.ensure_sync(handler)(e)
Path 4: 1 calls (0.01)
HTTPException (1)
HTTPException (1)
1def handle_http_exception(
2 self, e: HTTPException
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """Handles an HTTP exception. By default this will invoke the
5 registered error handlers and fall back to returning the
6 exception as response.
7
8 .. versionchanged:: 1.0.3
9 ``RoutingException``, used internally for actions such as
10 slash redirects during routing, is not passed to error
11 handlers.
12
13 .. versionchanged:: 1.0
14 Exceptions are looked up by code *and* by MRO, so
15 ``HTTPException`` subclasses can be handled with a catch-all
16 handler for the base ``HTTPException``.
17
18 .. versionadded:: 0.3
19 """
20 # Proxy exceptions don't have error codes. We want to always return
21 # those unchanged as errors
22 if e.code is None:
23 return e
24
25 # RoutingExceptions are used internally to trigger routing
26 # actions, such as slash redirects raising RequestRedirect. They
27 # are not raised or handled in user code.
28 if isinstance(e, RoutingException):
29 return e
30
31 handler = self._find_error_handler(e)
32 if handler is None:
33 return e
34 return self.ensure_sync(handler)(e)