'Register a function to handle errors by code or exception class.
A decorator that is used to register a function given an
error code.  Example::
@app.errorhandler(404)
def page_not_found(error):
return \'This page does not exist\', 404
You can also register handlers for arbitrary exceptions::
@app.errorhandler(DatabaseError)
def special_exception_handler(error):
return \'Database connection failed\', 500
.. versionadded:: 0.7
Use :meth:`register_error_handler` instead of modifying
:attr:`error_handler_spec` directly, for application wide error
handlers.
.. versionadded:: 0.7
One can now additionally also register custom exception types
that do not necessarily have to be a subclass of the
:class:`~werkzeug.exceptions.HTTPException` class.
:param code_or_exception: the code as integer for the handler, or
an arbitrary exception'

@setupmethod
def errorhandler(self, code_or_exception):

    def decorator(f):
        self._register_error_handler(None, code_or_exception, f)
        return f
    return decorator
