restructure: move backend into backend/
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
from fastapi import Request
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
|
||||
class APIError(Exception):
|
||||
"""Application error that maps to a JSON response with a status code."""
|
||||
|
||||
def __init__(self, status_code: int, detail: str):
|
||||
self.status_code = status_code
|
||||
self.detail = detail
|
||||
super().__init__(detail)
|
||||
|
||||
|
||||
async def api_error_handler(request: Request, exc: APIError) -> JSONResponse:
|
||||
return JSONResponse(status_code=exc.status_code, content={"detail": exc.detail})
|
||||
Reference in New Issue
Block a user