Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for Krause (0.15 sec)

  1. docs/en/docs/tutorial/handling-errors.md

    {!../../../docs_src/handling_errors/tutorial001.py!}
    ```
    
    ### Raise an `HTTPException` in your code
    
    `HTTPException` is a normal Python exception with additional data relevant for APIs.
    
    Because it's a Python exception, you don't `return` it, you `raise` it.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  2. docs/em/docs/tutorial/handling-errors.md

    ➡️ 💬 👆 ✔️ 🛃 ⚠ `UnicornException` 👈 👆 (⚖️ 🗃 👆 ⚙️) 💪 `raise`.
    
    & 👆 💚 🍵 👉 ⚠ 🌐 ⏮️ FastAPI.
    
    👆 💪 🚮 🛃 ⚠ 🐕‍🦺 ⏮️ `@app.exception_handler()`:
    
    ```Python hl_lines="5-7  13-18  24"
    {!../../../docs_src/handling_errors/tutorial003.py!}
    ```
    
    📥, 🚥 👆 📨 `/unicorns/yolo`, *➡ 🛠️* 🔜 `raise` `UnicornException`.
    
    ✋️ ⚫️ 🔜 🍵 `unicorn_exception_handler`.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 8.3K bytes
    - Viewed (0)
  3. docs/zh/docs/tutorial/handling-errors.md

    ```
    
    ### 触发 `HTTPException`
    
    `HTTPException` 是额外包含了和 API 有关数据的常规 Python 异常。
    
    因为是 Python 异常,所以不能 `return`,只能 `raise`。
    
    如在调用*路径操作函数*里的工具函数时,触发了 `HTTPException`,FastAPI 就不再继续执行*路径操作函数*中的后续代码,而是立即终止请求,并把 `HTTPException` 的 HTTP 错误发送至客户端。
    
    在介绍依赖项与安全的章节中,您可以了解更多用 `raise` 异常代替 `return` 值的优势。
    
    本例中,客户端用 `ID` 请求的 `item` 不存在时,触发状态码为 `404` 的异常:
    
    ```Python hl_lines="11"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 8.4K bytes
    - Viewed (0)
Back to top