HasErrorPrefix checks if the err is a Redis error and the message contains a prefix.
(err error, prefix string)
| 35 | |
| 36 | // HasErrorPrefix checks if the err is a Redis error and the message contains a prefix. |
| 37 | func HasErrorPrefix(err error, prefix string) bool { |
| 38 | var rErr Error |
| 39 | if !errors.As(err, &rErr) { |
| 40 | return false |
| 41 | } |
| 42 | msg := rErr.Error() |
| 43 | msg = strings.TrimPrefix(msg, "ERR ") // KVRocks adds such prefix |
| 44 | return strings.HasPrefix(msg, prefix) |
| 45 | } |
| 46 | |
| 47 | type Error interface { |
| 48 | error |