alexorlov commited on
Commit
cd59755
·
verified ·
1 Parent(s): 6ac566b

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app/main.py +14 -2
app/main.py CHANGED
@@ -1,6 +1,8 @@
1
  from contextlib import asynccontextmanager
2
- from fastapi import FastAPI
3
  from fastapi.middleware.cors import CORSMiddleware
 
 
4
 
5
  from app.config import get_settings
6
  from app.routers import health, session
@@ -23,9 +25,19 @@ app = FastAPI(
23
  title="AI Checklist Agent API",
24
  description="API для AI агента заполнения чеклиста созвона с клиентом",
25
  version="1.0.0",
26
- lifespan=lifespan
 
27
  )
28
 
 
 
 
 
 
 
 
 
 
29
  # Настройка CORS
30
  settings = get_settings()
31
  origins = settings.allowed_origins.split(",") if settings.allowed_origins != "*" else ["*"]
 
1
  from contextlib import asynccontextmanager
2
+ from fastapi import FastAPI, Request
3
  from fastapi.middleware.cors import CORSMiddleware
4
+ from fastapi.responses import JSONResponse
5
+ import traceback
6
 
7
  from app.config import get_settings
8
  from app.routers import health, session
 
25
  title="AI Checklist Agent API",
26
  description="API для AI агента заполнения чеклиста созвона с клиентом",
27
  version="1.0.0",
28
+ lifespan=lifespan,
29
+ debug=True
30
  )
31
 
32
+ @app.exception_handler(Exception)
33
+ async def global_exception_handler(request: Request, exc: Exception):
34
+ error_detail = f"{type(exc).__name__}: {str(exc)}\n{traceback.format_exc()}"
35
+ print(f"GLOBAL ERROR: {error_detail}")
36
+ return JSONResponse(
37
+ status_code=500,
38
+ content={"detail": error_detail}
39
+ )
40
+
41
  # Настройка CORS
42
  settings = get_settings()
43
  origins = settings.allowed_origins.split(",") if settings.allowed_origins != "*" else ["*"]