|
@@ -37,15 +37,6 @@ def boot(_app, provider):
|
|
|
logging.info(provider.__name__ + " booted")
|
|
|
|
|
|
|
|
|
-# 添加全局异常处理器
|
|
|
-@app.exception_handler(HTTPException)
|
|
|
-async def http_exception_handler(request, exc: HTTPException):
|
|
|
- return JSONResponse(
|
|
|
- status_code=exc.status_code,
|
|
|
- content={"detail": exc.detail, "message": "Resource not found."},
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
app = create_app()
|
|
|
|
|
|
|
|
@@ -63,3 +54,12 @@ if __name__ == "__main__":
|
|
|
# workers=settings.SERVER_WORKERS,
|
|
|
reload=settings.ENV == "local",
|
|
|
)
|
|
|
+
|
|
|
+
|
|
|
+# 添加全局异常处理器
|
|
|
+@app.exception_handler(HTTPException)
|
|
|
+async def http_exception_handler(request, exc: HTTPException):
|
|
|
+ return JSONResponse(
|
|
|
+ status_code=exc.status_code,
|
|
|
+ content={"detail": exc.detail, "message": "Resource not found."},
|
|
|
+ )
|