handle_user_exception() — flask Function Reference
Architecture documentation for the handle_user_exception() function in app.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 0b9edff8_7a0a_5286_0e0e_b7d04e6a35e6["handle_user_exception()"] 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"] 0b9edff8_7a0a_5286_0e0e_b7d04e6a35e6 -->|defined in| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 4deafda5_fb07_c30c_ad12_a72767b1a116["full_dispatch_request()"] 4deafda5_fb07_c30c_ad12_a72767b1a116 -->|calls| 0b9edff8_7a0a_5286_0e0e_b7d04e6a35e6 8f350fa4_a679_30fa_08ca_b4da93c5698c["handle_http_exception()"] 0b9edff8_7a0a_5286_0e0e_b7d04e6a35e6 -->|calls| 8f350fa4_a679_30fa_08ca_b4da93c5698c a89c0022_4807_bf16_9be1_6a66f3c78c9f["ensure_sync()"] 0b9edff8_7a0a_5286_0e0e_b7d04e6a35e6 -->|calls| a89c0022_4807_bf16_9be1_6a66f3c78c9f style 0b9edff8_7a0a_5286_0e0e_b7d04e6a35e6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/app.py lines 864–894
def handle_user_exception(
self, ctx: AppContext, e: Exception
) -> HTTPException | ft.ResponseReturnValue:
"""This method is called whenever an exception occurs that
should be handled. A special case is :class:`~werkzeug
.exceptions.HTTPException` which is forwarded to the
:meth:`handle_http_exception` method. This function will either
return a response value or reraise the exception with the same
traceback.
.. versionchanged:: 1.0
Key errors raised from request data like ``form`` show the
bad key in debug mode rather than a generic bad request
message.
.. versionadded:: 0.7
"""
if isinstance(e, BadRequestKeyError) and (
self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"]
):
e.show_exception = True
if isinstance(e, HTTPException) and not self.trap_http_exception(e):
return self.handle_http_exception(ctx, e)
handler = self._find_error_handler(e, ctx.request.blueprints)
if handler is None:
raise
return self.ensure_sync(handler)(e) # type: ignore[no-any-return]
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does handle_user_exception() do?
handle_user_exception() is a function in the flask codebase, defined in src/flask/app.py.
Where is handle_user_exception() defined?
handle_user_exception() is defined in src/flask/app.py at line 864.
What does handle_user_exception() call?
handle_user_exception() calls 2 function(s): ensure_sync, handle_http_exception.
What calls handle_user_exception()?
handle_user_exception() is called by 1 function(s): full_dispatch_request.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free