summaryrefslogtreecommitdiff
path: root/venv/lib/python3.11/site-packages/litestar/exceptions
diff options
context:
space:
mode:
Diffstat (limited to 'venv/lib/python3.11/site-packages/litestar/exceptions')
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/__init__.py42
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/__init__.cpython-311.pycbin1358 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/base_exceptions.cpython-311.pycbin4054 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/dto_exceptions.cpython-311.pycbin916 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/http_exceptions.cpython-311.pycbin7746 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/websocket_exceptions.cpython-311.pycbin2405 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/base_exceptions.py57
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/dto_exceptions.py13
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/http_exceptions.py154
-rw-r--r--venv/lib/python3.11/site-packages/litestar/exceptions/websocket_exceptions.py40
10 files changed, 0 insertions, 306 deletions
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/__init__.py b/venv/lib/python3.11/site-packages/litestar/exceptions/__init__.py
deleted file mode 100644
index 09065c8..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/__init__.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from .base_exceptions import LitestarException, LitestarWarning, MissingDependencyException, SerializationException
-from .dto_exceptions import DTOFactoryException, InvalidAnnotationException
-from .http_exceptions import (
- ClientException,
- HTTPException,
- ImproperlyConfiguredException,
- InternalServerException,
- MethodNotAllowedException,
- NoRouteMatchFoundException,
- NotAuthorizedException,
- NotFoundException,
- PermissionDeniedException,
- ServiceUnavailableException,
- TemplateNotFoundException,
- TooManyRequestsException,
- ValidationException,
-)
-from .websocket_exceptions import WebSocketDisconnect, WebSocketException
-
-__all__ = (
- "ClientException",
- "DTOFactoryException",
- "HTTPException",
- "ImproperlyConfiguredException",
- "InternalServerException",
- "InvalidAnnotationException",
- "LitestarException",
- "LitestarWarning",
- "MethodNotAllowedException",
- "MissingDependencyException",
- "NoRouteMatchFoundException",
- "NotAuthorizedException",
- "NotFoundException",
- "PermissionDeniedException",
- "SerializationException",
- "ServiceUnavailableException",
- "TemplateNotFoundException",
- "TooManyRequestsException",
- "ValidationException",
- "WebSocketDisconnect",
- "WebSocketException",
-)
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/__init__.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/__init__.cpython-311.pyc
deleted file mode 100644
index 1538618..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/__init__.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/base_exceptions.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/base_exceptions.cpython-311.pyc
deleted file mode 100644
index efd605d..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/base_exceptions.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/dto_exceptions.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/dto_exceptions.cpython-311.pyc
deleted file mode 100644
index 24633ee..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/dto_exceptions.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/http_exceptions.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/http_exceptions.cpython-311.pyc
deleted file mode 100644
index 76176d4..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/http_exceptions.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/websocket_exceptions.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/websocket_exceptions.cpython-311.pyc
deleted file mode 100644
index 90c2ce2..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/__pycache__/websocket_exceptions.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/base_exceptions.py b/venv/lib/python3.11/site-packages/litestar/exceptions/base_exceptions.py
deleted file mode 100644
index bbd4040..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/base_exceptions.py
+++ /dev/null
@@ -1,57 +0,0 @@
-from __future__ import annotations
-
-from typing import Any
-
-__all__ = ("MissingDependencyException", "SerializationException", "LitestarException", "LitestarWarning")
-
-
-class LitestarException(Exception):
- """Base exception class from which all Litestar exceptions inherit."""
-
- detail: str
-
- def __init__(self, *args: Any, detail: str = "") -> None:
- """Initialize ``LitestarException``.
-
- Args:
- *args: args are converted to :class:`str` before passing to :class:`Exception`
- detail: detail of the exception.
- """
- str_args = [str(arg) for arg in args if arg]
- if not detail:
- if str_args:
- detail, *str_args = str_args
- elif hasattr(self, "detail"):
- detail = self.detail
- self.detail = detail
- super().__init__(*str_args)
-
- def __repr__(self) -> str:
- if self.detail:
- return f"{self.__class__.__name__} - {self.detail}"
- return self.__class__.__name__
-
- def __str__(self) -> str:
- return " ".join((*self.args, self.detail)).strip()
-
-
-class MissingDependencyException(LitestarException, ImportError):
- """Missing optional dependency.
-
- This exception is raised only when a module depends on a dependency that has not been installed.
- """
-
- def __init__(self, package: str, install_package: str | None = None, extra: str | None = None) -> None:
- super().__init__(
- f"Package {package!r} is not installed but required. You can install it by running "
- f"'pip install litestar[{extra or install_package or package}]' to install litestar with the required extra "
- f"or 'pip install {install_package or package}' to install the package separately"
- )
-
-
-class SerializationException(LitestarException):
- """Encoding or decoding of an object failed."""
-
-
-class LitestarWarning(UserWarning):
- """Base class for Litestar warnings"""
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/dto_exceptions.py b/venv/lib/python3.11/site-packages/litestar/exceptions/dto_exceptions.py
deleted file mode 100644
index 037e3c6..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/dto_exceptions.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from __future__ import annotations
-
-from litestar.exceptions import LitestarException
-
-__all__ = ("DTOFactoryException", "InvalidAnnotationException")
-
-
-class DTOFactoryException(LitestarException):
- """Base DTO exception type."""
-
-
-class InvalidAnnotationException(DTOFactoryException):
- """Unexpected DTO type argument."""
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/http_exceptions.py b/venv/lib/python3.11/site-packages/litestar/exceptions/http_exceptions.py
deleted file mode 100644
index bd384c3..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/http_exceptions.py
+++ /dev/null
@@ -1,154 +0,0 @@
-from __future__ import annotations
-
-from http import HTTPStatus
-from typing import Any
-
-from litestar.exceptions.base_exceptions import LitestarException
-from litestar.status_codes import (
- HTTP_400_BAD_REQUEST,
- HTTP_401_UNAUTHORIZED,
- HTTP_403_FORBIDDEN,
- HTTP_404_NOT_FOUND,
- HTTP_405_METHOD_NOT_ALLOWED,
- HTTP_429_TOO_MANY_REQUESTS,
- HTTP_500_INTERNAL_SERVER_ERROR,
- HTTP_503_SERVICE_UNAVAILABLE,
-)
-
-__all__ = (
- "ClientException",
- "HTTPException",
- "ImproperlyConfiguredException",
- "InternalServerException",
- "MethodNotAllowedException",
- "NoRouteMatchFoundException",
- "NotAuthorizedException",
- "NotFoundException",
- "PermissionDeniedException",
- "ServiceUnavailableException",
- "TemplateNotFoundException",
- "TooManyRequestsException",
- "ValidationException",
-)
-
-
-class HTTPException(LitestarException):
- """Base exception for HTTP error responses.
-
- These exceptions carry information to construct an HTTP response.
- """
-
- status_code: int = HTTP_500_INTERNAL_SERVER_ERROR
- """Exception status code."""
- detail: str
- """Exception details or message."""
- headers: dict[str, str] | None
- """Headers to attach to the response."""
- extra: dict[str, Any] | list[Any] | None
- """An extra mapping to attach to the exception."""
-
- def __init__(
- self,
- *args: Any,
- detail: str = "",
- status_code: int | None = None,
- headers: dict[str, str] | None = None,
- extra: dict[str, Any] | list[Any] | None = None,
- ) -> None:
- """Initialize ``HTTPException``.
-
- Set ``detail`` and ``args`` if not provided.
-
- Args:
- *args: if ``detail`` kwarg not provided, first arg should be error detail.
- detail: Exception details or message. Will default to args[0] if not provided.
- status_code: Exception HTTP status code.
- headers: Headers to set on the response.
- extra: An extra mapping to attach to the exception.
- """
- super().__init__(*args, detail=detail)
- self.status_code = status_code or self.status_code
- self.extra = extra
- self.headers = headers
- if not self.detail:
- self.detail = HTTPStatus(self.status_code).phrase
- self.args = (f"{self.status_code}: {self.detail}", *self.args)
-
- def __repr__(self) -> str:
- return f"{self.status_code} - {self.__class__.__name__} - {self.detail}"
-
- def __str__(self) -> str:
- return " ".join(self.args).strip()
-
-
-class ImproperlyConfiguredException(HTTPException, ValueError):
- """Application has improper configuration."""
-
-
-class ClientException(HTTPException):
- """Client error."""
-
- status_code: int = HTTP_400_BAD_REQUEST
-
-
-class ValidationException(ClientException, ValueError):
- """Client data validation error."""
-
-
-class NotAuthorizedException(ClientException):
- """Request lacks valid authentication credentials for the requested resource."""
-
- status_code = HTTP_401_UNAUTHORIZED
-
-
-class PermissionDeniedException(ClientException):
- """Request understood, but not authorized."""
-
- status_code = HTTP_403_FORBIDDEN
-
-
-class NotFoundException(ClientException, ValueError):
- """Cannot find the requested resource."""
-
- status_code = HTTP_404_NOT_FOUND
-
-
-class MethodNotAllowedException(ClientException):
- """Server knows the request method, but the target resource doesn't support this method."""
-
- status_code = HTTP_405_METHOD_NOT_ALLOWED
-
-
-class TooManyRequestsException(ClientException):
- """Request limits have been exceeded."""
-
- status_code = HTTP_429_TOO_MANY_REQUESTS
-
-
-class InternalServerException(HTTPException):
- """Server encountered an unexpected condition that prevented it from fulfilling the request."""
-
- status_code: int = HTTP_500_INTERNAL_SERVER_ERROR
-
-
-class ServiceUnavailableException(InternalServerException):
- """Server is not ready to handle the request."""
-
- status_code = HTTP_503_SERVICE_UNAVAILABLE
-
-
-class NoRouteMatchFoundException(InternalServerException):
- """A route with the given name could not be found."""
-
-
-class TemplateNotFoundException(InternalServerException):
- """Referenced template could not be found."""
-
- def __init__(self, *args: Any, template_name: str) -> None:
- """Initialize ``TemplateNotFoundException``.
-
- Args:
- *args (Any): Passed through to ``super().__init__()`` - should not include ``detail``.
- template_name (str): Name of template that could not be found.
- """
- super().__init__(*args, detail=f"Template {template_name} not found.")
diff --git a/venv/lib/python3.11/site-packages/litestar/exceptions/websocket_exceptions.py b/venv/lib/python3.11/site-packages/litestar/exceptions/websocket_exceptions.py
deleted file mode 100644
index 2fed9ca..0000000
--- a/venv/lib/python3.11/site-packages/litestar/exceptions/websocket_exceptions.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from typing import Any
-
-from litestar.exceptions.base_exceptions import LitestarException
-from litestar.status_codes import WS_1000_NORMAL_CLOSURE
-
-__all__ = ("WebSocketDisconnect", "WebSocketException")
-
-
-class WebSocketException(LitestarException):
- """Exception class for websocket related events."""
-
- code: int
- """Exception code. For custom exceptions, this should be a number in the 4000+ range. Other codes can be found in
- ``litestar.status_code`` with the ``WS_`` prefix.
- """
-
- def __init__(self, *args: Any, detail: str, code: int = 4500) -> None:
- """Initialize ``WebSocketException``.
-
- Args:
- *args: Any exception args.
- detail: Exception details.
- code: Exception code. Should be a number in the >= 1000.
- """
- super().__init__(*args, detail=detail)
- self.code = code
-
-
-class WebSocketDisconnect(WebSocketException):
- """Exception class for websocket disconnect events."""
-
- def __init__(self, *args: Any, detail: str, code: int = WS_1000_NORMAL_CLOSURE) -> None:
- """Initialize ``WebSocketDisconnect``.
-
- Args:
- *args: Any exception args.
- detail: Exception details.
- code: Exception code. Should be a number in the >= 1000.
- """
- super().__init__(*args, detail=detail, code=code)