From 26c6c0aca1b9d01742c886be1a4dd76f3220d886 Mon Sep 17 00:00:00 2001 From: Abram Date: Tue, 21 Nov 2023 20:37:56 +0100 Subject: [PATCH] Update - handle explicit error + improve code-quality --- agenta-backend/agenta_backend/utils/redis_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agenta-backend/agenta_backend/utils/redis_utils.py b/agenta-backend/agenta_backend/utils/redis_utils.py index de352564ed..be3afe79bc 100644 --- a/agenta-backend/agenta_backend/utils/redis_utils.py +++ b/agenta-backend/agenta_backend/utils/redis_utils.py @@ -13,6 +13,10 @@ def redis_connection() -> redis.Redis: try: redis_client = redis.from_url(url=os.environ.get("REDIS_URL", None)) - except (ConnectionRefusedError, ConnectionError): - raise RuntimeError("Could not connect to redis service.") + except ConnectionRefusedError: + raise ConnectionRefusedError( + "Refuse connecting to redis service. Kindly check redis url." + ) + except ConnectionError: + raise ConnectionError("Could not connect to redis service.") return redis_client