Skip to content

Errors

Raise them to answer with an error, or with an exact response. See Errors and hooks.

HTTPException

HTTPException(status: int, detail: str | None = None, *, headers: HeaderItems = ())

Raise it to answer with an HTTP error: {"detail": ...} as JSON.

  • detail: the message; the standard reason if omitted
  • headers: extra response headers, a dict or pairs

Guide: https://3d3n-pyc.github.io/korvex/errors-and-hooks/

RequestValidationError

RequestValidationError(errors: list[dict])

Raised when a request doesn't match a handler's annotations: a 422 with errors.

Guide: https://3d3n-pyc.github.io/korvex/validation/#errors

Abort

Abort(response: Response)

Raise it to stop the request with this exact response, past exception handlers.

After hooks still apply. In a WebSocket's dependencies, it refuses the connection (403). Guide: https://3d3n-pyc.github.io/korvex/errors-and-hooks/