Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 32 for excption_handler (0.07 sec)

  1. docs/zh/docs/tutorial/handling-errors.md

    不过,也可以使用自定义处理器覆盖默认异常处理器。
    
    ### 覆盖请求验证异常
    
    请求中包含无效数据时,**FastAPI** 内部会触发 `RequestValidationError`。
    
    该异常也内置了默认异常处理器。
    
    覆盖默认异常处理器时需要导入 `RequestValidationError`,并用 `@app.excption_handler(RequestValidationError)` 装饰异常处理器。
    
    这样,异常处理器就可以接收 `Request` 与异常。
    
    {* ../../docs_src/handling_errors/tutorial004.py hl[2,14:16] *}
    
    访问 `/items/foo`,可以看到默认的 JSON 错误信息:
    
    ```JSON
    {
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Oct 11 17:48:49 UTC 2025
    - 8.2K bytes
    - Viewed (0)
  2. docs/de/docs/tutorial/handling-errors.md

    Und es enthält auch einen Default-Exceptionhandler für diesen.
    
    Um diesen zu überschreiben, importieren Sie den `RequestValidationError` und verwenden Sie ihn mit `@app.exception_handler(RequestValidationError)`, um den Exceptionhandler zu dekorieren.
    
    Der Exceptionhandler erhält einen `Request` und die Exception.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 10.4K bytes
    - Viewed (0)
  3. impl/maven-core/src/main/java/org/apache/maven/exception/ExceptionHandler.java

     * under the License.
     */
    package org.apache.maven.exception;
    
    /**
     * Transform an exception into useful end-user message.
     *
     * @since 3.0-alpha-3
     */
    public interface ExceptionHandler {
        ExceptionSummary handleException(Throwable e);
    Registered: Sun Dec 28 03:35:09 UTC 2025
    - Last Modified: Fri Oct 25 12:31:46 UTC 2024
    - 1023 bytes
    - Viewed (0)
  4. docs_src/handling_errors/tutorial006_py39.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 Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 928 bytes
    - Viewed (0)
  5. docs/ru/docs/tutorial/handling-errors.md

    И вы хотите обрабатывать это исключение глобально с помощью FastAPI.
    
    Можно добавить собственный обработчик исключений с помощью `@app.exception_handler()`:
    
    {* ../../docs_src/handling_errors/tutorial003_py39.py hl[5:7,13:18,24] *}
    
    Здесь, если запросить `/unicorns/yolo`, то *операция пути* вызовет `UnicornException`.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 14.1K bytes
    - Viewed (0)
  6. docs/uk/docs/tutorial/handling-errors.md

    І Ви хочете обробляти це виключення глобально за допомогою FastAPI.
    
    Ви можете додати власний обробник виключень за допомогою `@app.exception_handler()`:
    
    {* ../../docs_src/handling_errors/tutorial003.py hl[5:7,13:18,24] *}
    
    Тут, якщо Ви звернетеся до `/unicorns/yolo`, то згенерується помилка `UnicornException`.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Oct 11 17:48:49 UTC 2025
    - 13.9K bytes
    - Viewed (0)
  7. fastapi/exception_handlers.py

    Ben Beasley <******@****.***> 1758043308 +0100
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Sep 16 17:21:48 UTC 2025
    - 1.2K bytes
    - Viewed (0)
  8. tests/test_validation_error_context.py

    app.mount(path="/sub", app=sub_app)
    
    
    @app.exception_handler(RequestValidationError)
    @sub_app.exception_handler(RequestValidationError)
    async def request_validation_handler(request: Request, exc: RequestValidationError):
        captured_exception.capture(exc)
        raise exc
    
    
    @app.exception_handler(ResponseValidationError)
    @sub_app.exception_handler(ResponseValidationError)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 06 12:21:57 UTC 2025
    - 4.7K bytes
    - Viewed (0)
  9. docs/en/docs/tutorial/handling-errors.md

    Let's say you have a custom exception `UnicornException` that you (or a library you use) might `raise`.
    
    And you want to handle this exception globally with FastAPI.
    
    You could add a custom exception handler with `@app.exception_handler()`:
    
    {* ../../docs_src/handling_errors/tutorial003_py39.py hl[5:7,13:18,24] *}
    
    Here, if you request `/unicorns/yolo`, the *path operation* will `raise` a `UnicornException`.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 9K bytes
    - Viewed (0)
  10. docs/pt/docs/tutorial/handling-errors.md

    Nesse cenário, se você precisa manipular essa exceção de modo global com o FastAPI, você pode adicionar um manipulador de exceção customizada com `@app.exception_handler()`.
    
    {* ../../docs_src/handling_errors/tutorial003_py39.py hl[5:7,13:18,24] *}
    
    Nesse cenário, se você fizer uma requisição para `/unicorns/yolo`, a *operação de caminho* vai lançar (`raise`) o `UnicornException`.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 10.2K bytes
    - Viewed (0)
Back to top