Method: flask.app.Flask.handle_user_exception
Calls: 112, Exceptions: 0, Paths: 5Back
Path 1: 69 calls (0.62)
NotFound (16) Forbidden (16) MethodNotAllowed (15) InternalServerError (9) BadRequest (5) RequestRedirect (2) test_http_error_subclass_handling. MethodNotAllowed (15) NotFound (10) BadRequest (5) 'direct InternalServerError' (5) 'forbidden' (3) 'apple' (2) RequestRedirect (2) ('you shall not pa... Path 2: 25 calls (0.22) ZeroDivisionError (11) KeyError (4) Exception (2) TestGenericHandlers.Custom (2) ValueError (1) BadRequest (1) NotFound (1) DebugFilesKeyError (1) For... Path 3: 15 calls (0.13) Exception (1) AppError (1) BlueprintError (1) test_user_error_handling. ('', 412) (2) '42' (2) 'parent' (2) Response (1) 'Exception' (1) 'E2' (1) 'boom' (1) 'bam' (1) 'custom' (1) 'child-registered' (1) Path 4: 2 calls (0.02) BadRequestKeyError (2) Path 5: 1 calls (0.01) BadRequestKeyError (1) BadRequestKeyError (1)
1def handle_user_exception(
2 self, e: Exception
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """This method is called whenever an exception occurs that
5 should be handled. A special case is :class:`~werkzeug
6 .exceptions.HTTPException` which is forwarded to the
7 :meth:`handle_http_exception` method. This function will either
8 return a response value or reraise the exception with the same
9 traceback.
10
11 .. versionchanged:: 1.0
12 Key errors raised from request data like ``form`` show the
13 bad key in debug mode rather than a generic bad request
14 message.
15
16 .. versionadded:: 0.7
17 """
18 if isinstance(e, BadRequestKeyError) and (
19 self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]
20 ):
21 e.show_exception = True
22
23 if isinstance(e, HTTPException) and not self.trap_http_exception(e):
24 return self.handle_http_exception(e)
25
26 handler = self._find_error_handler(e)
27
28 if handler is None:
29 raise
30
31 return self.ensure_sync(handler)(e)
1def handle_user_exception(
2 self, e: Exception
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """This method is called whenever an exception occurs that
5 should be handled. A special case is :class:`~werkzeug
6 .exceptions.HTTPException` which is forwarded to the
7 :meth:`handle_http_exception` method. This function will either
8 return a response value or reraise the exception with the same
9 traceback.
10
11 .. versionchanged:: 1.0
12 Key errors raised from request data like ``form`` show the
13 bad key in debug mode rather than a generic bad request
14 message.
15
16 .. versionadded:: 0.7
17 """
18 if isinstance(e, BadRequestKeyError) and (
19 self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]
20 ):
21 e.show_exception = True
22
23 if isinstance(e, HTTPException) and not self.trap_http_exception(e):
24 return self.handle_http_exception(e)
25
26 handler = self._find_error_handler(e)
27
28 if handler is None:
29 raise
30
31 return self.ensure_sync(handler)(e)
1def handle_user_exception(
2 self, e: Exception
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """This method is called whenever an exception occurs that
5 should be handled. A special case is :class:`~werkzeug
6 .exceptions.HTTPException` which is forwarded to the
7 :meth:`handle_http_exception` method. This function will either
8 return a response value or reraise the exception with the same
9 traceback.
10
11 .. versionchanged:: 1.0
12 Key errors raised from request data like ``form`` show the
13 bad key in debug mode rather than a generic bad request
14 message.
15
16 .. versionadded:: 0.7
17 """
18 if isinstance(e, BadRequestKeyError) and (
19 self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]
20 ):
21 e.show_exception = True
22
23 if isinstance(e, HTTPException) and not self.trap_http_exception(e):
24 return self.handle_http_exception(e)
25
26 handler = self._find_error_handler(e)
27
28 if handler is None:
29 raise
30
31 return self.ensure_sync(handler)(e)
1def handle_user_exception(
2 self, e: Exception
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """This method is called whenever an exception occurs that
5 should be handled. A special case is :class:`~werkzeug
6 .exceptions.HTTPException` which is forwarded to the
7 :meth:`handle_http_exception` method. This function will either
8 return a response value or reraise the exception with the same
9 traceback.
10
11 .. versionchanged:: 1.0
12 Key errors raised from request data like ``form`` show the
13 bad key in debug mode rather than a generic bad request
14 message.
15
16 .. versionadded:: 0.7
17 """
18 if isinstance(e, BadRequestKeyError) and (
19 self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]
20 ):
21 e.show_exception = True
22
23 if isinstance(e, HTTPException) and not self.trap_http_exception(e):
24 return self.handle_http_exception(e)
25
26 handler = self._find_error_handler(e)
27
28 if handler is None:
29 raise
30
31 return self.ensure_sync(handler)(e)
1def handle_user_exception(
2 self, e: Exception
3 ) -> HTTPException | ft.ResponseReturnValue:
4 """This method is called whenever an exception occurs that
5 should be handled. A special case is :class:`~werkzeug
6 .exceptions.HTTPException` which is forwarded to the
7 :meth:`handle_http_exception` method. This function will either
8 return a response value or reraise the exception with the same
9 traceback.
10
11 .. versionchanged:: 1.0
12 Key errors raised from request data like ``form`` show the
13 bad key in debug mode rather than a generic bad request
14 message.
15
16 .. versionadded:: 0.7
17 """
18 if isinstance(e, BadRequestKeyError) and (
19 self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]
20 ):
21 e.show_exception = True
22
23 if isinstance(e, HTTPException) and not self.trap_http_exception(e):
24 return self.handle_http_exception(e)
25
26 handler = self._find_error_handler(e)
27
28 if handler is None:
29 raise
30
31 return self.ensure_sync(handler)(e)