src/flask/scaffold.py
def register_error_handler(
        self,
        code_or_exception: t.Union[t.Type[GenericException], int],
        f: "ErrorHandlerCallable[GenericException]",
    ) -> None:
        """Alternative error attach function to the :meth:`errorhandler`
        decorator that is more straightforward to use for non decorator
        usage.

        .. versionadded:: 0.7
        """
        if isinstance(code_or_exception, HTTPException):  # old broken behavior
            raise ValueError(
                "Tried to register a handler for an exception instance"
                f" {code_or_exception!r}. Handlers can only be"
                " registered for exception classes or HTTP error codes."
            )

        try:
            exc_class, code = self._get_exc_class_and_code(code_or_exception)
        except KeyError:
            raise KeyError(
                f"'{code_or_exception}' is not a recognized HTTP error"
                " code. Use a subclass of HTTPException with that code"
                " instead."
            ) from None

        self.error_handler_spec[None][code][exc_class] = t.cast(
            "ErrorHandlerCallable[Exception]", f
        )
Alternative error attach function to the :meth:`errorhandler`
        decorator that is more straightforward to use for non decorator
        usage.

        .. versionadded:: 0.7
        
Alternative error attach function to the :meth:`errorhandler`
decorator that is more straightforward to use for non decorator
usage.


Alternative error attach function to the : meth : ` errorhandler ` decorator that is more straightforward to use for non decorator usage .
def register_error_handler(
        self,
        code_or_exception: t.Union[t.Type[GenericException], int],
        f: "ErrorHandlerCallable[GenericException]",
    ) -> None:
        if isinstance(code_or_exception, HTTPException):  
            raise ValueError(
                "Tried to register a handler for an exception instance"
                f" {code_or_exception!r}. Handlers can only be"
                " registered for exception classes or HTTP error codes."
            )
        try:
            exc_class, code = self._get_exc_class_and_code(code_or_exception)
        except KeyError:
            raise KeyError(
                f"'{code_or_exception}' is not a recognized HTTP error"
                " code. Use a subclass of HTTPException with that code"
                " instead."
            ) from None
        self.error_handler_spec[None][code][exc_class] = t.cast(
            "ErrorHandlerCallable[Exception]", f
        )
def register_error_handler ( self , code_or_exception : t . Union [ t . Type [ GenericException ] , int ] , f : "ErrorHandlerCallable[GenericException]" , ) -> None : if isinstance ( code_or_exception , HTTPException ) : raise ValueError ( "Tried to register a handler for an exception instance" f" {code_or_exception!r}. Handlers can only be" " registered for exception classes or HTTP error codes." ) try : exc_class , code = self . _get_exc_class_and_code ( code_or_exception ) except KeyError : raise KeyError ( f"'{code_or_exception}' is not a recognized HTTP error" " code. Use a subclass of HTTPException with that code" " instead." ) from None self . error_handler_spec [ None ] [ code ] [ exc_class ] = t . cast ( "ErrorHandlerCallable[Exception]" , f )
Alternative error attach function to the :meth:`errorhandler`
decorator that is more straightforward to use for non decorator
usage.
Alternative error attach function to the : meth : ` errorhandler ` decorator that is more straightforward to use for non decorator usage .
"""Alternative error attach function to the :meth:`errorhandler`
        decorator that is more straightforward to use for non decorator
        usage.

        .. versionadded:: 0.7
        """ # old broken behavior
self
code_or_exception
t.Union[t.Type[GenericException], int]
f
"ErrorHandlerCallable[GenericException]"