Spaces:
Runtime error
Runtime error
Download cmsgpt/lib/python3.8/site-packages/fastapi/exceptions.py from AnshulKapoor/ChatCMS: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/AnshulKapoor/ChatCMS/resolve/main/cmsgpt/lib/python3.8/site-packages/fastapi/exceptions.py
- Command line
-
hf download hf://spaces/AnshulKapoor/ChatCMS/cmsgpt/lib/python3.8/site-packages/fastapi/exceptions.py
-
curl -L -o exceptions.py https://huggingface.co/spaces/AnshulKapoor/ChatCMS/resolve/main/cmsgpt/lib/python3.8/site-packages/fastapi/exceptions.py
1.21 kB
| from typing import Any, Dict, Optional, Sequence, Type | |
| from pydantic import BaseModel, ValidationError, create_model | |
| from pydantic.error_wrappers import ErrorList | |
| from starlette.exceptions import HTTPException as StarletteHTTPException | |
| from starlette.exceptions import WebSocketException as WebSocketException # noqa: F401 | |
| class HTTPException(StarletteHTTPException): | |
| def __init__( | |
| self, | |
| status_code: int, | |
| detail: Any = None, | |
| headers: Optional[Dict[str, str]] = None, | |
| ) -> None: | |
| super().__init__(status_code=status_code, detail=detail, headers=headers) | |
| RequestErrorModel: Type[BaseModel] = create_model("Request") | |
| WebSocketErrorModel: Type[BaseModel] = create_model("WebSocket") | |
| class FastAPIError(RuntimeError): | |
| """ | |
| A generic, FastAPI-specific error. | |
| """ | |
| class RequestValidationError(ValidationError): | |
| def __init__(self, errors: Sequence[ErrorList], *, body: Any = None) -> None: | |
| self.body = body | |
| super().__init__(errors, RequestErrorModel) | |
| class WebSocketRequestValidationError(ValidationError): | |
| def __init__(self, errors: Sequence[ErrorList]) -> None: | |
| super().__init__(errors, WebSocketErrorModel) | |