mirror of
https://github.com/redis/go-redis.git
synced 2025-11-04 02:33:24 +03:00
fix(panic): Return error instead of panic from commands (#3568)
Instead of panic in few commands, we can return an error to avoid unexpected panics in application code.
This commit is contained in:
@@ -693,7 +693,9 @@ func (c cmdable) MemoryUsage(ctx context.Context, key string, samples ...int) *I
|
||||
args := []interface{}{"memory", "usage", key}
|
||||
if len(samples) > 0 {
|
||||
if len(samples) != 1 {
|
||||
panic("MemoryUsage expects single sample count")
|
||||
cmd := NewIntCmd(ctx)
|
||||
cmd.SetErr(errors.New("MemoryUsage expects single sample count"))
|
||||
return cmd
|
||||
}
|
||||
args = append(args, "SAMPLES", samples[0])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user