birchrest.exceptions package
Submodules
birchrest.exceptions.api_error module
- exception birchrest.exceptions.api_error.ApiError(user_message: str, status_code: int)[source]
Bases:
ExceptionA custom exception class used to represent API errors. Each error has a status code, a user-friendly message, and a base message (from the HTTP status code description). It can also convert itself into an HTTP response.
- exception birchrest.exceptions.api_error.BadRequest(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 400 Bad Request error.
- exception birchrest.exceptions.api_error.Conflict(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 409 Conflict error.
- exception birchrest.exceptions.api_error.Forbidden(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 403 Forbidden error.
- exception birchrest.exceptions.api_error.Gone(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 410 Gone error.
- exception birchrest.exceptions.api_error.InternalServerError(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 500 Internal Server Error.
- exception birchrest.exceptions.api_error.LengthRequired(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 411 Length Required error.
- exception birchrest.exceptions.api_error.MethodNotAllowed(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 405 Method Not Allowed error.
- exception birchrest.exceptions.api_error.NotFound(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 404 Not Found error.
- exception birchrest.exceptions.api_error.PayloadTooLarge(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 413 Payload Too Large error.
- exception birchrest.exceptions.api_error.PaymentRequired(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 402 Payment Required error.
- exception birchrest.exceptions.api_error.PreconditionFailed(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 412 Precondition Failed error.
- exception birchrest.exceptions.api_error.RequestTimeout(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 408 Request Timeout error.
Bases:
ApiErrorRepresents a 503 Service Unavailable error.
- exception birchrest.exceptions.api_error.TooManyRequests(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 429 Too Many Requests error.
- exception birchrest.exceptions.api_error.Unauthorized(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 401 Unauthorized error.
- exception birchrest.exceptions.api_error.UnprocessableEntity(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 422 Unprocessable Entity error.
birchrest.exceptions.invalid_controller_registration module
birchrest.exceptions.missing_auth_handler_error module
Module contents
This module defines custom exceptions used throughout the BirchRest framework.
Exceptions: - InvalidControllerRegistration: Raised when a controller that does not inherit from the Controller base class is registered. - MissingAuthHandlerError: Raised when an authentication handler is required but has not been provided. - ApiError: Represents errors related to API requests, such as 404 Not Found or 500 Internal Server Error, with customizable status codes and messages.
These exceptions are used to manage error handling and enforce proper application behavior.
Exported exceptions: - InvalidControllerRegistration - MissingAuthHandlerError - ApiError
- exception birchrest.exceptions.ApiError(user_message: str, status_code: int)[source]
Bases:
ExceptionA custom exception class used to represent API errors. Each error has a status code, a user-friendly message, and a base message (from the HTTP status code description). It can also convert itself into an HTTP response.
- exception birchrest.exceptions.BadRequest(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 400 Bad Request error.
- exception birchrest.exceptions.Conflict(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 409 Conflict error.
- exception birchrest.exceptions.Forbidden(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 403 Forbidden error.
- exception birchrest.exceptions.Gone(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 410 Gone error.
- exception birchrest.exceptions.InternalServerError(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 500 Internal Server Error.
- exception birchrest.exceptions.InvalidControllerRegistration(received_object: Any)[source]
Bases:
ExceptionException raised when an invalid class or instance is registered as a controller.
- exception birchrest.exceptions.InvalidValidationModel(invalid_class: Type[Any])[source]
Bases:
TypeErrorException raised when the provided class is not a valid dataclass.
This error occurs when the user tries to use the validation decorators with a non-dataclass type. The error message will guide the user on how to resolve the issue by passing a proper dataclass to the validation decorators.
- exception birchrest.exceptions.LengthRequired(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 411 Length Required error.
- exception birchrest.exceptions.MethodNotAllowed(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 405 Method Not Allowed error.
- exception birchrest.exceptions.MissingAuthHandlerError[source]
Bases:
ExceptionException raised when a protected route is used without an authentication handler.
- exception birchrest.exceptions.NotFound(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 404 Not Found error.
- exception birchrest.exceptions.PayloadTooLarge(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 413 Payload Too Large error.
- exception birchrest.exceptions.PaymentRequired(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 402 Payment Required error.
- exception birchrest.exceptions.RequestTimeout(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 408 Request Timeout error.
Bases:
ApiErrorRepresents a 503 Service Unavailable error.
- exception birchrest.exceptions.TooManyRequests(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 429 Too Many Requests error.
- exception birchrest.exceptions.Unauthorized(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 401 Unauthorized error.
- exception birchrest.exceptions.UnprocessableEntity(user_message: str = '')[source]
Bases:
ApiErrorRepresents a 422 Unprocessable Entity error.