refactor: improve PDF extraction, error handling, and proxy configuration

This commit is contained in:
2026-06-30 10:39:27 +08:00
parent 1ccac1f29a
commit a2e3dc398b
7 changed files with 438 additions and 71 deletions
-10
View File
@@ -13,9 +13,7 @@ from app.config import settings
from app.exceptions import (
AppError,
ConflictError,
ExternalAPIError,
NotFoundError,
PdfProcessError,
ValidationError,
)
from app.database import engine, init_db
@@ -87,14 +85,6 @@ def create_app() -> FastAPI:
async def _validation_handler(request, exc):
return JSONResponse(status_code=400, content={"error": exc.message})
@app.exception_handler(ExternalAPIError)
async def _external_api_handler(request, exc):
return JSONResponse(status_code=502, content={"error": exc.message})
@app.exception_handler(PdfProcessError)
async def _pdf_process_handler(request, exc):
return JSONResponse(status_code=500, content={"error": exc.message})
@app.exception_handler(ConflictError)
async def _conflict_handler(request, exc):
return JSONResponse(status_code=409, content={"error": exc.message})