- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 10 for 418 (0.06 seconds)
-
tests/test_dependency_after_yield_raise.py
from fastapi.testclient import TestClient class CustomError(Exception): pass def catching_dep() -> Any: try: yield "s" except CustomError as err: raise HTTPException(status_code=418, detail="Session error") from err def broken_dep() -> Any: yield "s" raise ValueError("Broken after yield") app = FastAPI() @app.get("/catching")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 1.7K bytes - Click Count (0) -
docs_src/handling_errors/tutorial003_py310.py
self.name = name app = FastAPI() @app.exception_handler(UnicornException) async def unicorn_exception_handler(request: Request, exc: UnicornException): return JSONResponse( status_code=418, content={"message": f"Oops! {exc.name} did something. There goes a rainbow..."}, ) @app.get("/unicorns/{name}") async def read_unicorn(name: str): if name == "yolo":
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 626 bytes - Click Count (0) -
docs_src/bigger_applications/app_an_py310/main.py
app.include_router(users.router) app.include_router(items.router) app.include_router( admin.router, prefix="/admin", tags=["admin"], dependencies=[Depends(get_token_header)], responses={418: {"description": "I'm a teapot"}}, ) @app.get("/") async def root():
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 552 bytes - Click Count (0) -
docs_src/handling_errors/tutorial006_py310.py
return await request_validation_exception_handler(request, exc) @app.get("/items/{item_id}") async def read_item(item_id: int): if item_id == 3: raise HTTPException(status_code=418, detail="Nope! I don't like 3.")
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/en/docs/tutorial/handling-errors.md
Here, if you request `/unicorns/yolo`, the *path operation* will `raise` a `UnicornException`. But it will be handled by the `unicorn_exception_handler`. So, you will receive a clean error, with an HTTP status code of `418` and a JSON content of: ```JSON {"message": "Oops! yolo did something. There goes a rainbow..."} ``` /// note | Technical DetailsCreated: 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
return PlainTextResponse(message, status_code=400) @app.get("/items/{item_id}") async def read_item(item_id: int): if item_id == 3: raise HTTPException(status_code=418, detail="Nope! I don't like 3.")
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/tr/docs/tutorial/handling-errors.md
Burada `/unicorns/yolo` için request atarsanız, *path operation* bir `UnicornException` `raise` eder. Namun bu, `unicorn_exception_handler` tarafından handle edilir. Böylece HTTP status code’u `418` olan, JSON içeriği şu şekilde temiz bir hata response’u alırsınız: ```JSON {"message": "Oops! yolo did something. There goes a rainbow..."} ``` /// note | Teknik DetaylarCreated: 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/es/docs/tutorial/handling-errors.md
Aquí, si solicitas `/unicorns/yolo`, la *path operation* lanzará un `UnicornException`. Pero será manejado por el `unicorn_exception_handler`. Así que recibirás un error limpio, con un código de estado HTTP de `418` y un contenido JSON de: ```JSON {"message": "Oops! yolo did something. There goes a rainbow..."} ``` /// note | Nota TécnicaCreated: 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/zh/docs/tutorial/handling-errors.md
{* ../../docs_src/handling_errors/tutorial003_py310.py hl[5:7,13:18,24] *} 这里,请求 `/unicorns/yolo` 时,路径操作会触发 `UnicornException`。 但该异常将会被 `unicorn_exception_handler` 处理。 你会收到清晰的错误信息,HTTP 状态码为 `418`,JSON 内容如下: ```JSON {"message": "Oops! yolo did something. There goes a rainbow..."} ``` /// note | 技术细节 也可以使用 `from starlette.requests import Request` 和 `from starlette.responses import JSONResponse`。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
{* ../../docs_src/handling_errors/tutorial003_py310.py hl[5:7,13:18,24] *} 在這裡,如果你請求 `/unicorns/yolo`,該「路徑操作」會 `raise` 一個 `UnicornException`。 但它會被 `unicorn_exception_handler` 所處理。 因此你會得到一個乾淨的錯誤回應,HTTP 狀態碼為 `418`,JSON 內容如下: ```JSON {"message": "Oops! yolo did something. There goes a rainbow..."} ``` /// note | 技術細節 你也可以使用 `from starlette.requests import Request` 與 `from starlette.responses import JSONResponse`。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)