- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 35 for RequestValidationError (0.51 seconds)
-
docs_src/custom_request_and_route/tutorial002_py310.py
from collections.abc import Callable 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:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 10 08:55:32 GMT 2025 - 935 bytes - Click Count (0) -
docs/ja/docs/tutorial/handling-errors.md
/// /// warning | 注意 `RequestValidationError`には、検証エラーが発生したファイル名と行番号の情報が含まれているため、必要であれば関連情報と一緒にログに表示できます。 しかし、そのまま文字列に変換して直接その情報を返すと、システムに関する情報が多少漏えいする可能性があります。そのため、ここではコードが各エラーを個別に抽出して表示します。 /// ### `RequestValidationError`のボディの使用 { #use-the-requestvalidationerror-body } `RequestValidationError`には無効なデータを含む`body`が含まれています。 アプリ開発中にボディのログを取ってデバッグしたり、ユーザーに返したりなどに使用することができます。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:07:17 GMT 2026 - 11.2K bytes - Click Count (0) -
docs_src/custom_request_and_route/tutorial002_an_py310.py
from collections.abc import Callable from typing import Annotated 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:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 10 08:55:32 GMT 2025 - 974 bytes - Click Count (0) -
docs/en/docs/tutorial/handling-errors.md
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.
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 8.9K bytes - Click Count (0) -
docs_src/handling_errors/tutorial006_py310.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)}")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 928 bytes - Click Count (0) -
docs/ko/docs/how-to/custom-request-and-route.md
## 예외 핸들러에서 요청 바디 접근하기 { #accessing-the-request-body-in-an-exception-handler } /// tip | 팁 같은 문제를 해결하려면 `RequestValidationError`에 대한 커스텀 핸들러에서 `body`를 사용하는 편이 아마 훨씬 더 쉽습니다([오류 처리하기](../tutorial/handling-errors.md#use-the-requestvalidationerror-body)). 하지만 이 예시도 여전히 유효하며, 내부 컴포넌트와 상호작용하는 방법을 보여줍니다. /// 같은 접근 방식을 사용해 예외 핸들러에서 요청 바디에 접근할 수도 있습니다.Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:06:26 GMT 2026 - 5.2K bytes - Click Count (0) -
fastapi/exception_handlers.py
from fastapi.encoders import jsonable_encoder from fastapi.exceptions import RequestValidationError, WebSocketRequestValidationError from fastapi.utils import is_body_allowed_for_status_code from fastapi.websockets import WebSocket from starlette.exceptions import HTTPException from starlette.requests import Request from starlette.responses import JSONResponse, Response from starlette.status import WS_1008_POLICY_VIOLATION
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Sep 16 17:21:48 GMT 2025 - 1.2K bytes - Click Count (0) -
docs/en/docs/how-to/custom-request-and-route.md
/// tip To solve this same problem, it's probably a lot easier to use the `body` in a custom handler for `RequestValidationError` ([Handling Errors](../tutorial/handling-errors.md#use-the-requestvalidationerror-body)). But this example is still valid and it shows how to interact with the internal components. ///
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 4.4K bytes - Click Count (0) -
docs/zh-hant/docs/how-to/custom-request-and-route.md
但由於我們修改了 `GzipRequest.body`,在 **FastAPI** 需要讀取本文時,請求本文會自動解壓縮。 ## 在例外處理器中存取請求本文 { #accessing-the-request-body-in-an-exception-handler } /// tip 要解決相同問題,使用針對 `RequestValidationError` 的自訂處理器來讀取 `body` 通常更簡單([處理錯誤](../tutorial/handling-errors.md#use-the-requestvalidationerror-body))。 但本範例仍然有效,並示範了如何與內部元件互動。 /// 我們也可以用同樣的方法,在例外處理器中存取請求本文。 我們只需要在 `try`/`except` 區塊中處理請求即可:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 4.2K bytes - Click Count (0) -
docs/ja/docs/how-to/custom-request-and-route.md
## 例外ハンドラでのリクエストボディへのアクセス { #accessing-the-request-body-in-an-exception-handler } /// tip | 豆知識 同じ問題を解決するには、`RequestValidationError` 用のカスタムハンドラで `body` を使う方がずっと簡単でしょう([エラー処理](../tutorial/handling-errors.md#use-the-requestvalidationerror-body))。 ただし、この例も有効で、内部コンポーネントとどのようにやり取りするかを示しています。 /// 同じアプローチを使って、例外ハンドラ内でリクエストボディにアクセスすることもできます。 やることは、`try`/`except` ブロックの中でリクエストを処理するだけです:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:07:17 GMT 2026 - 5.4K bytes - Click Count (0)