- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 17 for excption_handler (0.31 sec)
-
docs/zh/docs/tutorial/handling-errors.md
不过,也可以使用自定义处理器覆盖默认异常处理器。 ### 覆盖请求验证异常 请求中包含无效数据时,**FastAPI** 内部会触发 `RequestValidationError`。 该异常也内置了默认异常处理器。 覆盖默认异常处理器时需要导入 `RequestValidationError`,并用 `@app.excption_handler(RequestValidationError)` 装饰异常处理器。 这样,异常处理器就可以接收 `Request` 与异常。 {* ../../docs_src/handling_errors/tutorial004.py hl[2,14:16] *} 访问 `/items/foo`,可以看到默认的 JSON 错误信息: ```JSON {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) -
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) -
fastapi/exception_handlers.py
Ben Beasley <******@****.***> 1758043308 +0100
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Tue Sep 16 17:21:48 UTC 2025 - 1.2K bytes - Viewed (0) -
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/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_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) -
impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorSubModulesTest.java
@Inject private LifeCyclePluginAnalyzer lifeCyclePluginAnalyzer; @Inject private LifecycleTaskSegmentCalculator lifeCycleTaskSegmentCalculator; @Inject private ExceptionHandler exceptionHandler; protected String getProjectsDirectory() { return "src/test/projects/lifecycle-executor"; } @Test void testCreation() throws Exception {Registered: Sun Dec 28 03:35:09 UTC 2025 - Last Modified: Fri Oct 25 12:31:46 UTC 2024 - 2.7K 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)