2019-08-30 17:30:03 -07:00
|
|
|
from typing import Any, Sequence
|
2019-05-30 19:43:02 +04:00
|
|
|
|
2019-05-29 16:27:55 +04:00
|
|
|
from pydantic import ValidationError
|
2019-08-30 17:30:03 -07:00
|
|
|
from pydantic.error_wrappers import ErrorList
|
2019-02-16 17:01:29 +04:00
|
|
|
from starlette.exceptions import HTTPException as StarletteHTTPException
|
2019-09-01 05:51:42 -07:00
|
|
|
from starlette.requests import Request
|
2019-08-30 17:30:03 -07:00
|
|
|
from starlette.websockets import WebSocket
|
2019-02-16 17:01:29 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class HTTPException(StarletteHTTPException):
|
|
|
|
|
def __init__(
|
2019-05-30 19:43:02 +04:00
|
|
|
self, status_code: int, detail: Any = None, headers: dict = None
|
2019-02-16 17:01:29 +04:00
|
|
|
) -> None:
|
|
|
|
|
super().__init__(status_code=status_code, detail=detail)
|
|
|
|
|
self.headers = headers
|
2019-05-29 16:27:55 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class RequestValidationError(ValidationError):
|
2019-08-30 17:30:03 -07:00
|
|
|
def __init__(self, errors: Sequence[ErrorList]) -> None:
|
|
|
|
|
super().__init__(errors, Request)
|
2019-05-29 16:27:55 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class WebSocketRequestValidationError(ValidationError):
|
2019-08-30 17:30:03 -07:00
|
|
|
def __init__(self, errors: Sequence[ErrorList]) -> None:
|
|
|
|
|
super().__init__(errors, WebSocket)
|