class_docstr: The exception to end the request handling and return an JSON error response.
  
  Examples:
  
  ```python
  from apiflask import APIFlask, HTTPError
  from markupsafe import escape
  
  app = APIFlask(__name__)
  
  @app.get('/<name>')
  def hello(name):
      if name == 'Foo':
          raise HTTPError(404, 'This man is missing.')
      return f'Hello, escape{name}'!
  ```
docstr: Initialize the error response.
  
  Arguments:
      status_code: The status code of the error (4XX and 5xx), defaults to 500.
      message: The simple description of the error. If not provided,
          the reason phrase of the status code will be used.
      detail: The detailed information of the error, you can use it to
          provide the addition information such as custom error code,
          documentation URL, etc.
      headers: A dict of headers used in the error response.
      extra_data: A dict of additional fields (custom error information) that will
          added to the error response body.
  
  *Version changed: 0.9.0*
  
  - Set `detail` and `headers` to empty dict if not set.
  
  *Version changed: 0.10.0*
  
  - Add `extra_data` parameter to accept additional error information.
  
  *Version changed: 0.11.0*
  
  - Change `status_code` from position argument to keyword argument, defaults to 500.
    Add class attributes with default values to support error subclasses.
code: def __init__(
      self,
      status_code: t.Optional[int] = None,
      message: t.Optional[str] = None,
      detail: t.Optional[t.Any] = None,
      headers: t.Optional[ResponseHeaderType] = None,
      extra_data: t.Optional[t.Mapping[str, t.Any]] = None,
  ) -> None:
      """Initialize the error response.
  
      Arguments:
          status_code: The status code of the error (4XX and 5xx), defaults to 500.
          message: The simple description of the error. If not provided,
              the reason phrase of the status code will be used.
          detail: The detailed information of the error, you can use it to
              provide the addition information such as custom error code,
              documentation URL, etc.
          headers: A dict of headers used in the error response.
          extra_data: A dict of additional fields (custom error information) that will
              added to the error response body.
  
      *Version changed: 0.9.0*
  
      - Set `detail` and `headers` to empty dict if not set.
  
      *Version changed: 0.10.0*
  
      - Add `extra_data` parameter to accept additional error information.
  
      *Version changed: 0.11.0*
  
      - Change `status_code` from position argument to keyword argument, defaults to 500.
        Add class attributes with default values to support error subclasses.
      """
      super().__init__()
      if status_code is not None:
          # TODO: support use custom error status code?
          if status_code not in default_exceptions:
              raise LookupError(
                  f"No exception for status code {status_code!r},"
                  ' valid error status code are "4XX" and "5XX".'
              )
          self.status_code = status_code
      if detail is not None:
          self.detail = detail
      if headers is not None:
          self.headers = headers
      if message is not None:
          self.message = message
      if extra_data is not None:
          self.extra_data = extra_data
  
      if self.message is None:
          # make sure the error message is not empty
          self.message: str = get_reason_phrase(
              self.status_code, "Unknown error"
          )
  
file_path: apiflask/src/apiflask/exceptions.py
imports: import typing
  from werkzeug.exceptions import default_exceptions
  from .helpers import get_reason_phrase
  from .types import ResponseHeaderType
label_desc: Use image node_id 1 to create a new HTTPError object from inherited base classes: Exception with example: obj = HTTPError(status_code, message, detail, headers, extra_data)