Add SimpleError

This commit is contained in:
tidwall 2022-08-25 16:56:07 -07:00
parent afd87a26a6
commit bc9875b4b0
1 changed files with 6 additions and 0 deletions

View File

@ -544,6 +544,10 @@ type SimpleString string
// from an *Any call.
type SimpleInt int
// SimpleError is for representing an error without adding the "ERR" prefix
// from an *Any call.
type SimpleError error
// Marshaler is the interface implemented by types that
// can marshal themselves into a Redis response type from an *Any call.
// The return value is not check for validity.
@ -570,6 +574,8 @@ func AppendAny(b []byte, v interface{}) []byte {
b = AppendString(b, string(v))
case SimpleInt:
b = AppendInt(b, int64(v))
case SimpleError:
b = AppendError(b, v.Error())
case nil:
b = AppendNull(b)
case error: