Skip to content

Commit

Permalink
redis: Fix error handling
Browse files Browse the repository at this point in the history
The error `redis.Nil` is only returned when no key is found in the Redis
database. In that case, we should only return and nil value instead of
an error. Therefore, this patch fixes the `Get` method to only return an
error when necessary.
João Neto authored and netoax committed Jul 1, 2021
1 parent 0fd7095 commit a6874a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/network/redis.go
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ func (r *Redis) Set(key string, value interface{}, expiration time.Duration) err
// Get retrieves a value from the Redis database according to key, which is returned as a string.
func (r *Redis) Get(key string) (string, error) {
val, err := r.rdb.Get(ctx, key).Result()
if err != redis.Nil {
if err != nil && err != redis.Nil {
return "", err
}

0 comments on commit a6874a3

Please sign in to comment.