From 01faa784ea2aa31ff7e7ac7c1543620469ace2f5 Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 1 Jun 2020 13:36:20 +0200 Subject: [PATCH] Add Redis connection error message --- src/redis_cache.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/redis_cache.nim b/src/redis_cache.nim index 8eb3bcb..f381f25 100644 --- a/src/redis_cache.nim +++ b/src/redis_cache.nim @@ -17,8 +17,12 @@ proc setCacheTimes*(cfg: Config) = listCacheTime = cfg.listCacheTime * 60 proc initRedisPool*(cfg: Config) = - pool = waitFor newRedisPool(cfg.redisConns, maxConns=cfg.redisMaxConns, - host=cfg.redisHost, port=cfg.redisPort) + try: + pool = waitFor newRedisPool(cfg.redisConns, maxConns=cfg.redisMaxConns, + host=cfg.redisHost, port=cfg.redisPort) + except OSError: + echo "Failed to connect to Redis." + quit() template toKey(p: Profile): string = "p:" & toLower(p.username) template toKey(v: Video): string = "v:" & v.videoId