class_docstr: Common behavior shared between :class:`~flask.Flask` and
  :class:`~flask.blueprints.Blueprint`.
  
  :param import_name: The import name of the module where this object
      is defined. Usually :attr:`__name__` should be used.
  :param static_folder: Path to a folder of static files to serve.
      If this is set, a static route will be added.
  :param static_url_path: URL prefix for the static route.
  :param template_folder: Path to a folder containing template files.
      for rendering. If this is set, a Jinja loader will be added.
  :param root_path: The path that static, template, and resource files
      are relative to. Typically not set, it is discovered based on
      the ``import_name``.
  
  .. versionadded:: 2.0
class_docstr_tok: ["Common","behavior","shared","between",":","class",":","`","~flask.Flask","`","and",":","class",":","`","~flask.blueprints.Blueprint","`",".",":","param","import_name",":","The","import","name","of","the","module","where","this","object","is","defined",".","Usually",":","attr",":","`","__name__","`","should","be","used",".",":","param","static_folder",":","Path","to","a","folder","of","static","files","to","serve",".","If","this","is","set",",","a","static","route","will","be","added",".",":","param","static_url_path",":","URL","prefix","for","the","static","route",".",":","param","template_folder",":","Path","to","a","folder","containing","template","files",".","for","rendering",".","If","this","is","set",",","a","Jinja","loader","will","be","added",".",":","param","root_path",":","The","path","that","static",",","template",",","and","resource","files","are","relative","to",".","Typically","not","set",",","it","is","discovered","based","on","the","``","import_name","``",".","..","versionadded",":",":","2.0"]
docstr: 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
  
  This is available on both app and blueprint objects. When used on an app, this
  can handle errors from every request. When used on a blueprint, this can handle
  errors from requests that the blueprint handles. To register with a blueprint
  and affect every request, use :meth:`.Blueprint.app_errorhandler`.
  
  .. 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
docstr_tok: ["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","This","is","available","on","both","app","and","blueprint","objects",".","When","used","on","an","app",",","this","can","handle","errors","from","every","request",".","When","used","on","a","blueprint",",","this","can","handle","errors","from","requests","that","the","blueprint","handles",".","To","register","with","a","blueprint","and","affect","every","request",",","use",":","meth",":","`",".Blueprint.app_errorhandler","`",".","..","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"]
code: def errorhandler(
      self, code_or_exception: type[Exception] | int
  ) -> t.Callable[[T_error_handler], T_error_handler]:
      """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
  
      This is available on both app and blueprint objects. When used on an app, this
      can handle errors from every request. When used on a blueprint, this can handle
      errors from requests that the blueprint handles. To register with a blueprint
      and affect every request, use :meth:`.Blueprint.app_errorhandler`.
  
      .. 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
      """
  
      def decorator(f: T_error_handler) -> T_error_handler:
          self.register_error_handler(code_or_exception, f)
          return f
  
      return decorator
  
imports: from __future__ import annotations
  import importlib.util
  import os
  import pathlib
  import sys
  import typing
  from collections import defaultdict
  from functools import update_wrapper
  from jinja2 import FileSystemLoader
  from werkzeug.exceptions import default_exceptions
  from werkzeug.exceptions import HTTPException
  from werkzeug.utils import cached_property
  from ..None import typing
  from ..cli import AppGroup
  from ..helpers import get_root_path
  from ..templating import _default_template_ctx_processor
label_desc: Use image node_id 25 for calling the Scaffold obj's underlying member method code with example usage: obj.errorhandler(code_or_exception) and returns: decorator, f