github.com/hdt3213/godis@v1.2.9/redis/protocol/errors.go (about) 1 package protocol 2 3 // UnknownErrReply represents UnknownErr 4 type UnknownErrReply struct{} 5 6 var unknownErrBytes = []byte("-Err unknown\r\n") 7 8 // ToBytes marshals redis.Reply 9 func (r *UnknownErrReply) ToBytes() []byte { 10 return unknownErrBytes 11 } 12 13 func (r *UnknownErrReply) Error() string { 14 return "Err unknown" 15 } 16 17 // ArgNumErrReply represents wrong number of arguments for command 18 type ArgNumErrReply struct { 19 Cmd string 20 } 21 22 // ToBytes marshals redis.Reply 23 func (r *ArgNumErrReply) ToBytes() []byte { 24 return []byte("-ERR wrong number of arguments for '" + r.Cmd + "' command\r\n") 25 } 26 27 func (r *ArgNumErrReply) Error() string { 28 return "ERR wrong number of arguments for '" + r.Cmd + "' command" 29 } 30 31 // MakeArgNumErrReply represents wrong number of arguments for command 32 func MakeArgNumErrReply(cmd string) *ArgNumErrReply { 33 return &ArgNumErrReply{ 34 Cmd: cmd, 35 } 36 } 37 38 // SyntaxErrReply represents meeting unexpected arguments 39 type SyntaxErrReply struct{} 40 41 var syntaxErrBytes = []byte("-Err syntax error\r\n") 42 var theSyntaxErrReply = &SyntaxErrReply{} 43 44 // MakeSyntaxErrReply creates syntax error 45 func MakeSyntaxErrReply() *SyntaxErrReply { 46 return theSyntaxErrReply 47 } 48 49 // ToBytes marshals redis.Reply 50 func (r *SyntaxErrReply) ToBytes() []byte { 51 return syntaxErrBytes 52 } 53 54 func (r *SyntaxErrReply) Error() string { 55 return "Err syntax error" 56 } 57 58 // WrongTypeErrReply represents operation against a key holding the wrong kind of value 59 type WrongTypeErrReply struct{} 60 61 var wrongTypeErrBytes = []byte("-WRONGTYPE Operation against a key holding the wrong kind of value\r\n") 62 63 // ToBytes marshals redis.Reply 64 func (r *WrongTypeErrReply) ToBytes() []byte { 65 return wrongTypeErrBytes 66 } 67 68 func (r *WrongTypeErrReply) Error() string { 69 return "WRONGTYPE Operation against a key holding the wrong kind of value" 70 } 71 72 // ProtocolErr 73 74 // ProtocolErrReply represents meeting unexpected byte during parse requests 75 type ProtocolErrReply struct { 76 Msg string 77 } 78 79 // ToBytes marshals redis.Reply 80 func (r *ProtocolErrReply) ToBytes() []byte { 81 return []byte("-ERR Protocol error: '" + r.Msg + "'\r\n") 82 } 83 84 func (r *ProtocolErrReply) Error() string { 85 return "ERR Protocol error '" + r.Msg + "' command" 86 }