Skip to content

Exceptions (fastapi_responseschema.exceptions)

Class BaseGenericHTTPException

class BaseGenericHTTPException(FastAPIHTTPException)

[view_source]

BaseClass for HTTPExceptions with additional data

__init__

def __init__(detail: Any = None,
             headers: Optional[Dict[str, Any]] = None,
             **extra_params: Any) -> None

[view_source]

Instances can be initialized with a set of extra params.

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class GenericHTTPException

class GenericHTTPException(BaseGenericHTTPException)

[view_source]

HTTP exception with extra data

__init__

def __init__(status_code: int,
             detail: Any = None,
             headers: Optional[Dict[str, Any]] = None,
             **extra_params: Any) -> None

[view_source]

Used to raise custom exceptions with extra params.

Arguments:

  • status_code int - Exception status code.
  • detail Any, optional - Error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - Error response data. Defaults to None.

Class BadRequest

class BadRequest(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 400

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class Unauthorized

class Unauthorized(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 401

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class Forbidden

class Forbidden(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 403

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class NotFound

class NotFound(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 404

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class MethodNotAllowed

class MethodNotAllowed(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 405

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class Conflict

class Conflict(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 409

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class Gone

class Gone(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 410

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class UnprocessableEntity

class UnprocessableEntity(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 422

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.

Class InternalServerError

class InternalServerError(BaseGenericHTTPException)

[view_source]

Raises with HTTP status 500

Arguments:

  • detail Any, optional - The error response content. Defaults to None.
  • headers Optional[Dict[str, Any]], optional - A set of headers to be returned in the response. Defaults to None.