| 123456789101112131415161718192021 |
- from __future__ import annotations
- from fastapi import FastAPI
- from fastapi.responses import JSONResponse
- from starlette.requests import Request
- from bom_assistant.api.routes import router
- from bom_assistant.scouting.errors import RowNotFoundError, SessionNotFoundError
- app = FastAPI(title="Instant BOM Assistant")
- app.include_router(router)
- @app.exception_handler(SessionNotFoundError)
- def _session_not_found(request: Request, exc: SessionNotFoundError) -> JSONResponse:
- return JSONResponse(status_code=404, content={"detail": str(exc)})
- @app.exception_handler(RowNotFoundError)
- def _row_not_found(request: Request, exc: RowNotFoundError) -> JSONResponse:
- return JSONResponse(status_code=404, content={"detail": str(exc)})
|