- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 18 for exception_handler (0.34 sec)
-
tests/test_validation_error_context.py
app.mount(path="/sub", app=sub_app) @app.exception_handler(RequestValidationError) @sub_app.exception_handler(RequestValidationError) async def request_validation_handler(request: Request, exc: RequestValidationError): captured_exception.capture(exc) raise exc @app.exception_handler(ResponseValidationError) @sub_app.exception_handler(ResponseValidationError)
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 06 12:21:57 UTC 2025 - 4.7K bytes - Viewed (0) -
docs_src/handling_errors/tutorial006_py39.py
from fastapi import FastAPI, HTTPException from fastapi.exception_handlers import ( http_exception_handler, request_validation_exception_handler, ) from fastapi.exceptions import RequestValidationError from starlette.exceptions import HTTPException as StarletteHTTPException app = FastAPI() @app.exception_handler(StarletteHTTPException) async def custom_http_exception_handler(request, exc): print(f"OMG! An HTTP error!: {repr(exc)}")
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
from starlette.exceptions import HTTPException as StarletteHTTPException app = FastAPI() @app.exception_handler(StarletteHTTPException) async def http_exception_handler(request, exc): return PlainTextResponse(str(exc.detail), status_code=exc.status_code) @app.exception_handler(RequestValidationError) async def validation_exception_handler(request, exc: RequestValidationError): message = "Validation errors:"
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 920 bytes - Viewed (0) -
docs_src/handling_errors/tutorial003_py39.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 Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 626 bytes - Viewed (0) -
docs_src/handling_errors/tutorial005_py39.py
from fastapi.encoders import jsonable_encoder from fastapi.exceptions import RequestValidationError from fastapi.responses import JSONResponse from pydantic import BaseModel app = FastAPI() @app.exception_handler(RequestValidationError) async def validation_exception_handler(request: Request, exc: RequestValidationError): return JSONResponse( status_code=422,
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 626 bytes - Viewed (0) -
docs/en/docs/reference/fastapi.md
- put - post - delete - options - head - patch - trace - on_event - middlewareRegistered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Thu Apr 18 19:53:19 UTC 2024 - 701 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()`: {* ../../docs_src/handling_errors/tutorial003_py39.py hl[5:7,13:18,24] *} Here, if you request `/unicorns/yolo`, the *path operation* will `raise` a `UnicornException`.
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 9K bytes - Viewed (0) -
docs/es/docs/tutorial/handling-errors.md
Y quieres manejar esta excepción globalmente con FastAPI. Podrías agregar un manejador de excepciones personalizado con `@app.exception_handler()`: {* ../../docs_src/handling_errors/tutorial003_py39.py hl[5:7,13:18,24] *} Aquí, si solicitas `/unicorns/yolo`, la *path operation* lanzará un `UnicornException`.Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 9.7K bytes - Viewed (0) -
docs/zh/docs/tutorial/handling-errors.md
## 安装自定义异常处理器 添加自定义处理器,要使用 [Starlette 的异常工具](https://www.starlette.dev/exceptions/)。 假设要触发的自定义异常叫作 `UnicornException`。 且需要 FastAPI 实现全局处理该异常。 此时,可以用 `@app.exception_handler()` 添加自定义异常控制器: {* ../../docs_src/handling_errors/tutorial003.py hl[5:7,13:18,24] *} 请求 `/unicorns/yolo` 时,路径操作会触发 `UnicornException`。 但该异常将会被 `unicorn_exception_handler` 处理。Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Oct 11 17:48:49 UTC 2025 - 8.2K bytes - Viewed (0) -
impl/maven-core/src/main/java/org/apache/maven/exception/ExceptionHandler.java
* under the License. */ package org.apache.maven.exception; /** * Transform an exception into useful end-user message. * * @since 3.0-alpha-3 */ public interface ExceptionHandler { ExceptionSummary handleException(Throwable e);Registered: Sun Dec 28 03:35:09 UTC 2025 - Last Modified: Fri Oct 25 12:31:46 UTC 2024 - 1023 bytes - Viewed (0)