Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 12 for StarletteHTTPException (0.07 sec)

  1. docs_src/handling_errors/tutorial006_py39.py

        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)}")
        return await http_exception_handler(request, exc)
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 928 bytes
    - Viewed (0)
  2. docs_src/handling_errors/tutorial004_py39.py

    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)
    
    
    @app.exception_handler(RequestValidationError)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 920 bytes
    - Viewed (0)
  3. tests/test_starlette_exception.py

    from fastapi import FastAPI, HTTPException
    from fastapi.testclient import TestClient
    from starlette.exceptions import HTTPException as StarletteHTTPException
    
    app = FastAPI()
    
    items = {"foo": "The Foo Wrestlers"}
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id: str):
        if item_id not in items:
            raise HTTPException(
                status_code=404,
                detail="Item not found",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 7.4K bytes
    - Viewed (0)
  4. fastapi/exceptions.py

    from pydantic import BaseModel, create_model
    from starlette.exceptions import HTTPException as StarletteHTTPException
    from starlette.exceptions import WebSocketException as StarletteWebSocketException
    
    
    class EndpointContext(TypedDict, total=False):
        function: str
        path: str
        file: str
        line: int
    
    
    class HTTPException(StarletteHTTPException):
        """
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 12:54:56 UTC 2025
    - 6.8K bytes
    - Viewed (0)
  5. docs/ru/docs/tutorial/handling-errors.md

    В данном примере, чтобы иметь возможность использовать оба `HTTPException` в одном коде, исключения Starlette переименованы в `StarletteHTTPException`:
    
    ```Python
    from starlette.exceptions import HTTPException as StarletteHTTPException
    ```
    
    ### Переиспользование обработчиков исключений **FastAPI** { #reuse-fastapis-exception-handlers }
    
    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/de/docs/tutorial/handling-errors.md

    Um in diesem Beispiel beide `HTTPException`s im selben Code zu haben, wird die Exception von Starlette zu `StarletteHTTPException` umbenannt:
    
    ```Python
    from starlette.exceptions import HTTPException as StarletteHTTPException
    ```
    
    ### Die Exceptionhandler von **FastAPI** wiederverwenden { #reuse-fastapis-exception-handlers }
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 10.4K bytes
    - Viewed (0)
  7. docs/uk/docs/tutorial/handling-errors.md

    У цьому прикладі, щоб мати можливість використовувати обидва `HTTPException` в одному коді, помилка Starlette перейменовується на `StarletteHTTPException`:
    
    ```Python
    from starlette.exceptions import HTTPException as StarletteHTTPException
    ```
    
    ### Повторне використання обробників помилок **FastAPI**
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Oct 11 17:48:49 UTC 2025
    - 13.9K bytes
    - Viewed (0)
  8. docs/zh/docs/tutorial/handling-errors.md

    这样做是为了,当 Starlette 的内部代码、扩展或插件触发 Starlette `HTTPException` 时,处理程序能够捕获、并处理此异常。
    
    注意,本例代码中同时使用了这两个 `HTTPException`,此时,要把 Starlette 的 `HTTPException` 命名为 `StarletteHTTPException`:
    
    ```Python
    from starlette.exceptions import HTTPException as StarletteHTTPException
    
    ```
    
    ### 复用 **FastAPI** 异常处理器
    
    FastAPI 支持先对异常进行某些处理,然后再使用 **FastAPI** 中处理该异常的默认异常处理器。
    
    从 `fastapi.exception_handlers` 中导入要复用的默认异常处理器:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Oct 11 17:48:49 UTC 2025
    - 8.2K bytes
    - Viewed (0)
  9. docs/en/docs/tutorial/handling-errors.md

    In this example, to be able to have both `HTTPException`s in the same code, Starlette's exceptions is renamed to `StarletteHTTPException`:
    
    ```Python
    from starlette.exceptions import HTTPException as StarletteHTTPException
    ```
    
    ### Reuse **FastAPI**'s exception handlers { #reuse-fastapis-exception-handlers }
    
    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

    Neste exemplo, para poder ter ambos os `HTTPException` no mesmo código, a exceção do Starlette é renomeada para `StarletteHTTPException`:
    
    ```Python
    from starlette.exceptions import HTTPException as StarletteHTTPException
    ```
    
    ### Reutilize os manipuladores de exceção do **FastAPI** { #reuse-fastapis-exception-handlers }
    
    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