Source code for duck.exceptions.all

"""
Module containing Duck error classes.
"""


[docs] class BaseException(Exception): """ Base class for all errors. """ def __init__(self, message, **kws): """ Stores the error message in the `message` attribute. Args: message (str): The error message. **kws: Additional keyword arguments. """ self.message = message
[docs] def __str__(self): """ Returns the error message. """ return f"{self.message}"
[docs] class AsyncViolationError(BaseException): """ Raised on operations which violates asynchronous way of doing things. """
[docs] class ExpectingNoResponse(BaseException): """ Exception raised when we are expecting a response yet we are never going to get any. Useful in cases where methods like `get_response` are expecting a response e.g. from a WebSocketView yet this view handles everything on its own and no response is supposed to be returned. """
[docs] class DisallowedAction(BaseException): """ Raised on disallowed actions. """
[docs] class ServerError(BaseException): """ Server based exceptions. """
[docs] class ApplicationError(BaseException): """ Raised on application related errors. """
[docs] class BlueprintError(BaseException): """ Raised for blueprint-related errors. """
[docs] class PortError(BaseException): """ Raised on port conflict errors. """
[docs] class RequestError(BaseException): """ Raised for request errors. """
[docs] class RequestHostError(RequestError): """ Raised on request host errors. """
[docs] class MethodNotAllowedError(RequestError): """ Raised on disallowed request method. """
[docs] class RequestSyntaxError(RequestError): """ Raised on request syntax errors. """
[docs] class RequestUnsupportedVersionError(RequestError): """ Raised on unsupported HTTP version. """
[docs] class RequestTimeoutError(RequestError): """ Raised on request timeouts. """
[docs] class HeaderError(BaseException): """ Raised on header-related exceptions. """
[docs] class RouteError(BaseException): """ Raised on errors related to routes and route configuration. """
[docs] class RouteNotFoundError(BaseException): """ Raised on unregistered or unknown routes. """
[docs] class FunctionError(BaseException): """ Raised on function errors. """
[docs] class CustomHeadersJsonLoadError(BaseException): """ Raised when there's an error loading custom headers from JSON. """
[docs] class MiddlewareError(ApplicationError): """ Raised when there's an error on any middleware. """
[docs] class MiddlewareLoadError(MiddlewareError): """ Raised when there's an error loading or importing a middleware. """
[docs] class NormalizerError(BaseException): """ Raised when there's an error on any normalizer. """
[docs] class NormalizerLoadError(NormalizerError): """ Raised when there's an error loading or importing a normalizer. """
[docs] class CSRFMiddlewareError(MiddlewareError): """ Raised when there's an error in CSRF middleware. """
[docs] class NormalizationError(BaseException): """ Raised when there's an error in normalization process. """
[docs] class SettingsError(BaseException): """ Raised for errors in the app's settings configuration. """
[docs] class ContentError(BaseException): """ Raised for error related to setting content of an HttpResponse. """
[docs] class TemplateError(BaseException): """ Raised for any errors related to templates. """
[docs] class TemplateNotFound(TemplateError): """ Raised when a template could not be found. """
[docs] class SSLError(BaseException): """ Raised when ssl certfile or ssl private key is not found in locations specified in settings.py if and only if `ENABLE_HTTPS=True` """
[docs] class MultiPartParserError(BaseException): """ Exception when parsing multipart/form-data """