chore: initial project scaffold and gitignore
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""Exception types and FastAPI handlers."""
|
||||
|
||||
from fastapi import FastAPI, Request, status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
|
||||
class PortfolioHubError(Exception):
|
||||
"""Base application exception."""
|
||||
|
||||
|
||||
class FeatureNotReadyError(PortfolioHubError):
|
||||
"""Raised when an endpoint contract exists but the implementation is pending."""
|
||||
|
||||
|
||||
def register_exception_handlers(app: FastAPI) -> None:
|
||||
@app.exception_handler(FeatureNotReadyError)
|
||||
async def handle_not_ready(_: Request, exc: FeatureNotReadyError) -> JSONResponse:
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED,
|
||||
content={"detail": str(exc) or "Feature not implemented yet"},
|
||||
)
|
||||
Reference in New Issue
Block a user