Skip to content

Commit

Permalink
Update - handle explicit error + improve code-quality
Browse files Browse the repository at this point in the history
  • Loading branch information
aybruhm committed Nov 21, 2023
1 parent bb914fd commit 26c6c0a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions agenta-backend/agenta_backend/utils/redis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 26c6c0a

Please sign in to comment.