Skip to content

Commit 354f166

Browse files
committed
fix: improve error handling for Redis connection failures
Signed-off-by: binaryYuki <60097976+binaryYuki@users.noreply.github.com>
1 parent 8c03313 commit 354f166

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,11 @@ async def healthz():
195195
f = await redis_client.ping()
196196
if f:
197197
return JSONResponse(content={"status": "ok", "message": "Redis connection established"}, status_code=200)
198+
else:
199+
return JSONResponse(content={"status": "error", "error": "redis conection failed code: 1000"},
200+
status_code=500)
198201
except Exception as e:
199-
return JSONResponse(content={"status": "error", "error": f"Failed to connect to Redis: {e}"}, status_code=500)
202+
return JSONResponse(content={"status": "error", "error": f"redis conection failed code: 1001"}, status_code=500)
200203

201204

202205
@app.middleware("http")

0 commit comments

Comments
 (0)