- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 24 for 418 (0.03 sec)
-
docs_src/handling_errors/tutorial003_py39.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":
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 626 bytes - Viewed (0) -
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")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 1.7K bytes - Viewed (0) -
docs_src/bigger_applications/app_py39/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():
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 552 bytes - Viewed (0) -
docs_src/handling_errors/tutorial006_py39.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.")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 928 bytes - Viewed (0) -
docs_src/handling_errors/tutorial004_py39.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.")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 920 bytes - Viewed (0) -
tests/test_tutorial/test_handling_errors/test_tutorial006.py
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 3.6K bytes - Viewed (0) -
tests/test_tutorial/test_handling_errors/test_tutorial003.py
assert response.status_code == 200, response.text assert response.json() == {"unicorn_name": "shinny"} def test_get_exception(): response = client.get("/unicorns/yolo") assert response.status_code == 418, response.text assert response.json() == { "message": "Oops! yolo did something. There goes a rainbow..." } def test_openapi_schema(): response = client.get("/openapi.json")Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 3.2K bytes - Viewed (0) -
tests/test_tutorial/test_handling_errors/test_tutorial004.py
assert "Validation errors:" in response.text assert "Field: ('path', 'item_id')" in response.text def test_get_http_error(): response = client.get("/items/3") assert response.status_code == 418, response.text assert response.content == b"Nope! I don't like 3." def test_get(): response = client.get("/items/2") assert response.status_code == 200, response.text
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 3.4K bytes - Viewed (0) -
docs/ru/docs/tutorial/handling-errors.md
Здесь, если запросить `/unicorns/yolo`, то *операция пути* вызовет `UnicornException`. Но оно будет обработано `unicorn_exception_handler`. Таким образом, вы получите чистую ошибку с кодом состояния HTTP `418` и содержимым JSON: ```JSON {"message": "Oops! yolo did something. There goes a rainbow..."} ``` /// note | Технические деталиRegistered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 14.1K bytes - Viewed (0) -
docs/uk/docs/tutorial/handling-errors.md
Тут, якщо Ви звернетеся до `/unicorns/yolo`, то згенерується помилка `UnicornException`. Але вона буде оброблена функцією-обробником `unicorn_exception_handler`. Отже, Ви отримаєте зрозумілу помилку зі HTTP-статусом `418` і JSON-відповіддю: ```JSON {"message": "Oops! yolo did something. There goes a rainbow..."} ``` /// note | Технічні деталіRegistered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Oct 11 17:48:49 UTC 2025 - 13.9K bytes - Viewed (0)