From e29fb2c08d148353cd0781c20a2af205b53bca63 Mon Sep 17 00:00:00 2001 From: Jeremy Epstein Date: Tue, 11 Nov 2025 10:43:17 +1100 Subject: [PATCH] Tweak wording of dependency with yield exception message Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com> --- fastapi/dependencies/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index a927dbb69..668d46cba 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -559,9 +559,8 @@ async def _solve_generator( dependency_name = getattr(call, "__name__", "(unknown)") raise FastAPIError( f"Dependency {dependency_name} raised: {ex}. There's a high chance that " - "this is a dependency with yield that has a block with a bare except, or a " - "block with except Exception, and is not raising the exception again. Read " - "more about it in the docs: " + "this is a dependency with yield that catches an exception using except, " + "but doesn't raise the exception again. Read more about it in the docs: " "https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield" "/#dependencies-with-yield-and-except" ) from ex