aboutsummaryrefslogtreecommitdiff
path: root/app/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.py')
-rw-r--r--app/main.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/main.py b/app/main.py
index 3ef89f2..90b3104 100644
--- a/app/main.py
+++ b/app/main.py
@@ -1,6 +1,6 @@
from fastapi import FastAPI, Depends, Request
from fastapi.middleware.cors import CORSMiddleware
-from fastapi.responses import RedirectResponse
+from fastapi.responses import RedirectResponse, JSONResponse
from fastapi.templating import Jinja2Templates
from app.routes.auth_routes import router as auth_router
from app.routes.links_routes import router as links_router
@@ -151,3 +151,11 @@ async def redirect_to_docs():
@app.exception_handler(HTTP_404_NOT_FOUND)
async def custom_404_handler(request: Request, exc: HTTPException):
return RedirectResponse(url="/login")
+
+
+@app.exception_handler(HTTPException)
+async def http_exception_handler(request, exc):
+ return JSONResponse(
+ status_code=exc.status_code,
+ content={"detail": f"{exc.detail}"},
+ )