Spaces:
Runtime error
Runtime error
Download venv/Lib/site-packages/fastapi/exceptions.py from uday987/pythonProject16: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/spaces/uday987/pythonProject16/resolve/main/venv/Lib/site-packages/fastapi/exceptions.py
- Command line
-
hf download hf://spaces/uday987/pythonProject16/venv/Lib/site-packages/fastapi/exceptions.py
-
curl -L -o exceptions.py https://huggingface.co/spaces/uday987/pythonProject16/resolve/main/venv/Lib/site-packages/fastapi/exceptions.py
1.59 kB
| from typing import Any, Dict, Optional, Sequence, Type | |
| from pydantic import BaseModel, create_model | |
| 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 ValidationException(Exception): | |
| def __init__(self, errors: Sequence[Any]) -> None: | |
| self._errors = errors | |
| def errors(self) -> Sequence[Any]: | |
| return self._errors | |
| class RequestValidationError(ValidationException): | |
| def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None: | |
| super().__init__(errors) | |
| self.body = body | |
| class WebSocketRequestValidationError(ValidationException): | |
| pass | |
| class ResponseValidationError(ValidationException): | |
| def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None: | |
| super().__init__(errors) | |
| self.body = body | |
| def __str__(self) -> str: | |
| message = f"{len(self._errors)} validation errors:\n" | |
| for err in self._errors: | |
| message += f" {err}\n" | |
| return message | |