Home / Function/ _find_error_handler() — flask Function Reference

_find_error_handler() — flask Function Reference

Architecture documentation for the _find_error_handler() function in app.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  ee25cbe7_f849_f0aa_f045_a06792ee042e["_find_error_handler()"]
  38f6d4a2_834e_2acd_e1b6_f45c58079ccd["App"]
  ee25cbe7_f849_f0aa_f045_a06792ee042e -->|defined in| 38f6d4a2_834e_2acd_e1b6_f45c58079ccd
  3b660c5d_ab73_8e46_a1e8_f86033a43906["_get_exc_class_and_code()"]
  ee25cbe7_f849_f0aa_f045_a06792ee042e -->|calls| 3b660c5d_ab73_8e46_a1e8_f86033a43906
  cd459c23_b1c5_45ac_a393_26c2ff268367["get()"]
  ee25cbe7_f849_f0aa_f045_a06792ee042e -->|calls| cd459c23_b1c5_45ac_a393_26c2ff268367
  style ee25cbe7_f849_f0aa_f045_a06792ee042e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/sansio/app.py lines 865–888

    def _find_error_handler(
        self, e: Exception, blueprints: list[str]
    ) -> ft.ErrorHandlerCallable | None:
        """Return a registered error handler for an exception in this order:
        blueprint handler for a specific code, app handler for a specific code,
        blueprint handler for an exception class, app handler for an exception
        class, or ``None`` if a suitable handler is not found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))
        names = (*blueprints, None)

        for c in (code, None) if code is not None else (None,):
            for name in names:
                handler_map = self.error_handler_spec[name][c]

                if not handler_map:
                    continue

                for cls in exc_class.__mro__:
                    handler = handler_map.get(cls)

                    if handler is not None:
                        return handler
        return None

Subdomains

Frequently Asked Questions

What does _find_error_handler() do?
_find_error_handler() is a function in the flask codebase, defined in src/flask/sansio/app.py.
Where is _find_error_handler() defined?
_find_error_handler() is defined in src/flask/sansio/app.py at line 865.
What does _find_error_handler() call?
_find_error_handler() calls 2 function(s): _get_exc_class_and_code, get.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free