- Sort Score
- Num 10 results
- Language All
Results 1 - 9 of 9 for StarletteHTTPException (0.12 seconds)
-
docs_src/handling_errors/tutorial006_py310.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)Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 928 bytes - Click Count (0) -
tests/test_starlette_exception.py
from fastapi import FastAPI, HTTPException from fastapi.testclient import TestClient from inline_snapshot import snapshot 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",
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Feb 08 10:18:38 GMT 2026 - 8.1K bytes - Click Count (0) -
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): """
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Feb 11 18:41:21 GMT 2026 - 7.3K bytes - Click Count (0) -
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 }
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/tutorial004_py310.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)
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 920 bytes - Click Count (0) -
docs/es/docs/tutorial/handling-errors.md
En este ejemplo, para poder tener ambos `HTTPException` en el mismo código, las excepciones de Starlette son renombradas a `StarletteHTTPException`: ```Python from starlette.exceptions import HTTPException as StarletteHTTPException ``` ### Reutilizar los manejadores de excepciones de **FastAPI** { #reuse-fastapis-exception-handlers }Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 19 18:15:55 GMT 2026 - 9.6K bytes - Click Count (0) -
docs/tr/docs/tutorial/handling-errors.md
Bu örnekte, iki `HTTPException`’ı da aynı kodda kullanabilmek için Starlette’in exception’ı `StarletteHTTPException` olarak yeniden adlandırılıyor: ```Python from starlette.exceptions import HTTPException as StarletteHTTPException ``` ### **FastAPI**’nin Exception Handler’larını Yeniden Kullanmak { #reuse-fastapis-exception-handlers }Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 07:53:17 GMT 2026 - 9.7K bytes - Click Count (0) -
docs/zh/docs/tutorial/handling-errors.md
但注册异常处理器时,应该注册到来自 Starlette 的 `HTTPException`。 这样做是为了,当 Starlette 的内部代码、扩展或插件触发 Starlette `HTTPException` 时,你的处理器能够捕获并处理它。 本例中,为了在同一份代码中同时使用两个 `HTTPException`,将 Starlette 的异常重命名为 `StarletteHTTPException`: ```Python from starlette.exceptions import HTTPException as StarletteHTTPException ``` ### 复用 **FastAPI** 的异常处理器 { #reuse-fastapis-exception-handlers } 如果你想在自定义处理后仍复用 **FastAPI** 的默认异常处理器,可以从 `fastapi.exception_handlers` 导入并复用这些默认处理器:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:06:37 GMT 2026 - 8.2K bytes - Click Count (0) -
docs/zh-hant/docs/tutorial/handling-errors.md
如此一來,如果 Starlette 的內部程式碼,或任何 Starlette 擴充/外掛 raise 了 Starlette 的 `HTTPException`,你的處理器就能攔截並處理它。 在這個範例中,為了能在同一份程式碼中同時使用兩種 `HTTPException`,我們把 Starlette 的例外重新命名為 `StarletteHTTPException`: ```Python from starlette.exceptions import HTTPException as StarletteHTTPException ``` ### 重用 **FastAPI** 的例外處理器 { #reuse-fastapis-exception-handlers } 如果你想在使用例外的同時,沿用 **FastAPI** 的預設例外處理器,你可以從 `fastapi.exception_handlers` 匯入並重用預設的處理器:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 8.3K bytes - Click Count (0)