mirror of
https://github.com/fastapi/fastapi.git
synced 2026-09-14 13:36:21 +08:00
62af6e0eeb
* ✨ Implement separated ValidationError handlers and custom exceptions * ✅ Add tutorial source examples and tests * 📝 Add docs for custom exception handlers * 📝 Update docs section titles
19 lines
484 B
Python
19 lines
484 B
Python
from pydantic import ValidationError
|
|
from starlette.exceptions import HTTPException as StarletteHTTPException
|
|
|
|
|
|
class HTTPException(StarletteHTTPException):
|
|
def __init__(
|
|
self, status_code: int, detail: str = None, headers: dict = None
|
|
) -> None:
|
|
super().__init__(status_code=status_code, detail=detail)
|
|
self.headers = headers
|
|
|
|
|
|
class RequestValidationError(ValidationError):
|
|
pass
|
|
|
|
|
|
class WebSocketRequestValidationError(ValidationError):
|
|
pass
|