- Sort Score
- Result 10 results
- Languages All
Results 11 - 20 of 20 for Exceptionhandler (0.12 sec)
-
docs_src/handling_errors/tutorial003.py
from fastapi import FastAPI, Request from fastapi.responses import JSONResponse class UnicornException(Exception): def __init__(self, name: str): self.name = name app = FastAPI() @app.exception_handler(UnicornException) async def unicorn_exception_handler(request: Request, exc: UnicornException): return JSONResponse( status_code=418,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Mar 26 19:09:53 UTC 2020 - 626 bytes - Viewed (0) -
docs/en/docs/reference/fastapi.md
- put - post - delete - options - head - patch - trace - on_event - middleware
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:53:19 UTC 2024 - 701 bytes - Viewed (0) -
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`.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 8.3K bytes - Viewed (0) -
docs/en/docs/tutorial/handling-errors.md
Let's say you have a custom exception `UnicornException` that you (or a library you use) might `raise`. And you want to handle this exception globally with FastAPI. You could add a custom exception handler with `@app.exception_handler()`: ```Python hl_lines="5-7 13-18 24" {!../../docs_src/handling_errors/tutorial003.py!} ``` Here, if you request `/unicorns/yolo`, the *path operation* will `raise` a `UnicornException`.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 9.1K bytes - Viewed (0) -
docs/ru/docs/tutorial/handling-errors.md
И вы хотите обрабатывать это исключение глобально с помощью FastAPI. Можно добавить собственный обработчик исключений с помощью `@app.exception_handler()`: ```Python hl_lines="5-7 13-18 24" {!../../docs_src/handling_errors/tutorial003.py!} ``` Здесь, если запросить `/unicorns/yolo`, то *операция пути* вызовет `UnicornException`.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 14.5K bytes - Viewed (0) -
docs/pt/docs/tutorial/handling-errors.md
Nesse cenário, se você precisa manipular essa exceção de modo global com o FastAPI, você pode adicionar um manipulador de exceção customizada com `@app.exception_handler()`. ```Python hl_lines="5-7 13-18 24" {!../../docs_src/handling_errors/tutorial003.py!} ```
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 10K bytes - Viewed (0) -
docs/de/docs/advanced/middleware.md
``` Aber FastAPI (eigentlich Starlette) bietet eine einfachere Möglichkeit, welche sicherstellt, dass die internen Middlewares zur Behandlung von Serverfehlern und benutzerdefinierten Exceptionhandlern ordnungsgemäß funktionieren. Dazu verwenden Sie `app.add_middleware()` (wie schon im Beispiel für CORS gesehen). ```Python from fastapi import FastAPI from unicorn import UnicornMiddleware app = FastAPI()
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 4.3K bytes - Viewed (0) -
docs/ja/docs/tutorial/handling-errors.md
あなた(または使用しているライブラリ)が`raise`するかもしれないカスタム例外`UnicornException`があるとしましょう。 そして、この例外をFastAPIでグローバルに処理したいと思います。 カスタム例外ハンドラを`@app.exception_handler()`で追加することができます: ```Python hl_lines="5 6 7 13 14 15 16 17 18 24" {!../../docs_src/handling_errors/tutorial003.py!} ``` ここで、`/unicorns/yolo`をリクエストすると、*path operation*は`UnicornException`を`raise`します。
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 11.8K bytes - Viewed (0) -
docs/zh/docs/tutorial/handling-errors.md
``` ## 安装自定义异常处理器 添加自定义处理器,要使用 [Starlette 的异常工具](https://www.starlette.io/exceptions/)。 假设要触发的自定义异常叫作 `UnicornException`。 且需要 FastAPI 实现全局处理该异常。 此时,可以用 `@app.exception_handler()` 添加自定义异常控制器: ```Python hl_lines="5-7 13-18 24" {!../../docs_src/handling_errors/tutorial003.py!} ``` 请求 `/unicorns/yolo` 时,路径操作会触发 `UnicornException`。
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 8.4K bytes - Viewed (0) -
fastapi/applications.py
], Doc( """ A dictionary with handlers for exceptions. In FastAPI, you would normally use the decorator `@app.exception_handler()`. Read more in the [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/). """ ), ] = None,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Aug 17 04:52:31 UTC 2024 - 172.2K bytes - Viewed (0)