🌐 Add Chinese translation for docs/zh/docs/tutorial/dependencies/dependencies-with-yield.md#3494
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3494 +/- ##
===========================================
Coverage 100.00% 100.00%
===========================================
Files 540 254 -286
Lines 13969 7860 -6109
===========================================
- Hits 13969 7860 -6109 ☔ View full report in Codecov by Sentry. |
|
📝 Docs preview for commit fba3fb5 at: https://60e57a08e48305314659b399--fastapi.netlify.app |
|
|
||
| 把依赖项的 `yield` 置于 `try` 代码块中,就可以接收到所有使用该依赖项时触发的异常。 | ||
|
|
||
| 假设执行过程中的某行代码(这行代码可能在*路径操作或其他依赖项中*)导致了数据库事务的「回滚」,或导致了任何其他错误,使用 `try` 就可以在当前依赖项中触发异常。 |
There was a problem hiding this comment.
| 假设执行过程中的某行代码(这行代码可能在*路径操作或其他依赖项中*)导致了数据库事务的「回滚」,或导致了任何其他错误,使用 `try` 就可以在当前依赖项中触发异常。 | |
| 假设执行过程中的某行代码(这行代码可能在*路径操作或其他依赖项中*)导致了数据库事务的「回滚」,或导致了任何其他错误,使用 `try` 就可以在当前依赖项中触发异常。 |
|
|
||
| 通过这种方式,**FastAPI** 允许依赖项中的任意对象(例如,数据库会话)都可以用于后台任务。 | ||
|
|
||
| 后台任务是在响应发送*后*执行的任务。所以,此时抛出 HTTPException 没有意义,因为没有办法改变*已发送*的响应。 |
There was a problem hiding this comment.
| 后台任务是在响应发送*后*执行的任务。所以,此时抛出 HTTPException 没有意义,因为没有办法改变*已发送*的响应。 | |
| 后台任务是在响应发送*后*执行的任务。所以,此时抛出 HTTPException 没有意义,因为没有办法改变*已发送*的响应。 |
|
|
||
| !!! tip "提示" | ||
|
|
||
| 不要在 `yield` 语句之后,而是要在该语句之前触发 `HTTPException` 等异常。 |
There was a problem hiding this comment.
| 不要在 `yield` 语句之后,而是要在该语句之前触发 `HTTPException` 等异常。 | |
| 在依赖项的 `yield` 语句之前抛出 `HTTPException` 等异常仍然是可行的,但不能在 `yield` 之后。 |
docs/tutorial/dependencies/dependencies-with-yield.md
change 其他 to 其它 change 开发人员 to 开发者 change 「」 to bold for better reading experience
…dencies-dependencies-with-yield.md
|
📝 Docs preview for commit 979ade8 at: https://6499d1a2bac8cd0a1954b002--fastapi.netlify.app |
docs/tutorial/dependencies/dependencies-with-yield.mddocs/zh/docs/tutorial/dependencies/dependencies-with-yield.md
|
Hi! This one was already handled in #10870. For now, I'll close this one, but thanks for the help @jaystone776 @waynerv 🚀 |
…ield.md
as title