MCPcopy
hub / github.com/redis/go-redis / HasErrorPrefix

Function HasErrorPrefix

error.go:37–45  ·  view source on GitHub ↗

HasErrorPrefix checks if the err is a Redis error and the message contains a prefix.

(err error, prefix string)

Source from the content-addressed store, hash-verified

35
36// HasErrorPrefix checks if the err is a Redis error and the message contains a prefix.
37func 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
47type Error interface {
48 error

Callers 3

EvalShaMethod · 0.85
EvalShaROMethod · 0.85
evalMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected