Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 21 for RequestValidationError (0.35 sec)

  1. 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.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  2. 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.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:28:29 GMT 2024
    - 10.6K bytes
    - Viewed (0)
  3. 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 HTTP_422_UNPROCESSABLE_ENTITY, WS_1008_POLICY_VIOLATION
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Jun 11 19:08:14 GMT 2023
    - 1.3K bytes
    - Viewed (0)
  4. docs/ru/docs/tutorial/handling-errors.md

    Когда запрос содержит недопустимые данные, **FastAPI** внутренне вызывает ошибку `RequestValidationError`.
    
    А также включает в себя обработчик исключений по умолчанию.
    
    Чтобы переопределить его, импортируйте `RequestValidationError` и используйте его с `@app.exception_handler(RequestValidationError)` для создания обработчика исключений.
    
    Обработчик исключения получит объект `Request` и исключение.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 14.5K bytes
    - Viewed (0)
  5. 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,
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 667 bytes
    - Viewed (0)
  6. 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:
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 932 bytes
    - Viewed (0)
  7. docs_src/handling_errors/tutorial004.py

    from fastapi import FastAPI, HTTPException
    from fastapi.exceptions import RequestValidationError
    from fastapi.responses import PlainTextResponse
    from starlette.exceptions import HTTPException as StarletteHTTPException
    
    app = FastAPI()
    
    
    @app.exception_handler(StarletteHTTPException)
    async def http_exception_handler(request, exc):
        return PlainTextResponse(str(exc.detail), status_code=exc.status_code)
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 762 bytes
    - Viewed (0)
  8. 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!}
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 10K bytes
    - Viewed (0)
  9. 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!}
    
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 8.4K bytes
    - Viewed (0)
  10. 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"})
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Feb 17 12:40:12 GMT 2022
    - 1.9K bytes
    - Viewed (0)
Back to top