- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 21 for RequestValidationError (0.11 sec)
-
tests/test_exception_handlers.py
import pytest from fastapi import FastAPI, HTTPException from fastapi.exceptions import RequestValidationError from fastapi.testclient import TestClient from starlette.responses import JSONResponse def http_exception_handler(request, exception): return JSONResponse({"exception": "http-exception"}) def request_validation_exception_handler(request, exception): return JSONResponse({"exception": "request-validation"})
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Feb 17 12:40:12 UTC 2022 - 1.9K bytes - Viewed (0) -
docs_src/handling_errors/tutorial005.py
from fastapi.encoders import jsonable_encoder from fastapi.exceptions import RequestValidationError from fastapi.responses import JSONResponse from pydantic import BaseModel app = FastAPI() @app.exception_handler(RequestValidationError) async def validation_exception_handler(request: Request, exc: RequestValidationError): return JSONResponse( status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Mar 26 19:09:53 UTC 2020 - 667 bytes - Viewed (0) -
docs/em/docs/tutorial/handling-errors.md
👆 💪 🔐 👫 ⚠ 🐕🦺 ⏮️ 👆 👍. ### 🔐 📨 🔬 ⚠ 🕐❔ 📨 🔌 ❌ 📊, **FastAPI** 🔘 🤚 `RequestValidationError`. & ⚫️ 🔌 🔢 ⚠ 🐕🦺 ⚫️. 🔐 ⚫️, 🗄 `RequestValidationError` & ⚙️ ⚫️ ⏮️ `@app.exception_handler(RequestValidationError)` 🎀 ⚠ 🐕🦺. ⚠ 🐕🦺 🔜 📨 `Request` & ⚠. ```Python hl_lines="2 14-16" {!../../docs_src/handling_errors/tutorial004.py!} ```
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 8.3K bytes - Viewed (0) -
docs_src/custom_request_and_route/tutorial002.py
from typing import Callable, List from fastapi import Body, FastAPI, HTTPException, Request, Response from fastapi.exceptions import RequestValidationError from fastapi.routing import APIRoute class ValidationErrorLoggingRoute(APIRoute): def get_route_handler(self) -> Callable: original_route_handler = super().get_route_handler() async def custom_route_handler(request: Request) -> Response: try:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 932 bytes - Viewed (0) -
docs/pt/docs/tutorial/handling-errors.md
## Sobrescreva exceções de validação da requisição Quando a requisição contém dados inválidos, **FastAPI** internamente lança para o `RequestValidationError`. Para sobrescrevê-lo, importe o `RequestValidationError` e use-o com o `@app.exception_handler(RequestValidationError)` para decorar o manipulador de exceções. ```Python hl_lines="2 14-16" {!../../docs_src/handling_errors/tutorial004.py!} ```
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 10K bytes - Viewed (0) -
docs/en/docs/tutorial/handling-errors.md
### Override request validation exceptions When a request contains invalid data, **FastAPI** internally raises a `RequestValidationError`. And it also includes a default exception handler for it. To override it, import the `RequestValidationError` and use it with `@app.exception_handler(RequestValidationError)` to decorate the exception handler. The exception handler will receive a `Request` and the exception.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 9.1K bytes - Viewed (0) -
docs/ru/docs/tutorial/handling-errors.md
Когда запрос содержит недопустимые данные, **FastAPI** внутренне вызывает ошибку `RequestValidationError`. А также включает в себя обработчик исключений по умолчанию. Чтобы переопределить его, импортируйте `RequestValidationError` и используйте его с `@app.exception_handler(RequestValidationError)` для создания обработчика исключений. Обработчик исключения получит объект `Request` и исключение.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 14.5K bytes - Viewed (0) -
docs/zh/docs/tutorial/handling-errors.md
触发 `HTTPException` 或请求无效数据时,这些处理器返回默认的 JSON 响应结果。 不过,也可以使用自定义处理器覆盖默认异常处理器。 ### 覆盖请求验证异常 请求中包含无效数据时,**FastAPI** 内部会触发 `RequestValidationError`。 该异常也内置了默认异常处理器。 覆盖默认异常处理器时需要导入 `RequestValidationError`,并用 `@app.excption_handler(RequestValidationError)` 装饰异常处理器。 这样,异常处理器就可以接收 `Request` 与异常。 ```Python hl_lines="2 14-16" {!../../docs_src/handling_errors/tutorial004.py!} ```
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 8.4K bytes - Viewed (0) -
docs_src/handling_errors/tutorial006.py
from fastapi import FastAPI, HTTPException from fastapi.exception_handlers import ( http_exception_handler, request_validation_exception_handler, ) from fastapi.exceptions import RequestValidationError from starlette.exceptions import HTTPException as StarletteHTTPException app = FastAPI() @app.exception_handler(StarletteHTTPException) async def custom_http_exception_handler(request, exc): print(f"OMG! An HTTP error!: {repr(exc)}")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Aug 09 11:10:33 UTC 2020 - 928 bytes - Viewed (0) -
docs/de/docs/tutorial/handling-errors.md
Wenn ein Request ungültige Daten enthält, löst **FastAPI** intern einen `RequestValidationError` aus. Und bietet auch einen Default-Exceptionhandler dafür. Um diesen zu überschreiben, importieren Sie den `RequestValidationError` und verwenden Sie ihn in `@app.exception_handler(RequestValidationError)`, um Ihren Exceptionhandler zu dekorieren.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 10.6K bytes - Viewed (0)