From bf11595be9e40214aef9b0c7c6d67c8dd248aa6d Mon Sep 17 00:00:00 2001 From: ziro Date: Mon, 17 Jul 2023 08:35:33 +0700 Subject: [PATCH] feat: Handle code 500 --- nexus/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nexus/app.py b/nexus/app.py index 83e94f1..1ce57e6 100644 --- a/nexus/app.py +++ b/nexus/app.py @@ -4,7 +4,7 @@ import uvicorn from dotenv import load_dotenv -from fastapi import HTTPException +from fastapi import HTTPException, Request from starlette.responses import JSONResponse from nexus.core import constants, routes @@ -38,5 +38,10 @@ async def errorHandler(request, exc): return resp +@app.exception_handler(500) +async def internalServerErrorHandler(request: Request, exc: Exception): + return JSONResponse(status_code=500, content={"code": 500, "msg": "Internal Server Error"}) + + if __name__ == "__main__": uvicorn.run("nexus.app:app", reload=DEBUG)