Files
redis-go/redis/reply/errors.go
2021-05-13 08:56:07 +08:00

74 lines
1.8 KiB
Go

package reply
// UnknownErrReply represents UnknownErr
type UnknownErrReply struct{}
var unknownErrBytes = []byte("-Err unknown\r\n")
// ToBytes marshals redis.Reply
func (r *UnknownErrReply) ToBytes() []byte {
return unknownErrBytes
}
func (r *UnknownErrReply) Error() string {
return "Err unknown"
}
// ArgNumErrReply represents wrong number of arguments for command
type ArgNumErrReply struct {
Cmd string
}
// ToBytes marshals redis.Reply
func (r *ArgNumErrReply) ToBytes() []byte {
return []byte("-ERR wrong number of arguments for '" + r.Cmd + "' command\r\n")
}
func (r *ArgNumErrReply) Error() string {
return "ERR wrong number of arguments for '" + r.Cmd + "' command"
}
// SyntaxErrReply represents meeting unexpected arguments
type SyntaxErrReply struct{}
var syntaxErrBytes = []byte("-Err syntax error\r\n")
// ToBytes marshals redis.Reply
func (r *SyntaxErrReply) ToBytes() []byte {
return syntaxErrBytes
}
func (r *SyntaxErrReply) Error() string {
return "Err syntax error"
}
// WrongTypeErrReply represents operation against a key holding the wrong kind of value
type WrongTypeErrReply struct{}
var wrongTypeErrBytes = []byte("-WRONGTYPE Operation against a key holding the wrong kind of value\r\n")
// ToBytes marshals redis.Reply
func (r *WrongTypeErrReply) ToBytes() []byte {
return wrongTypeErrBytes
}
func (r *WrongTypeErrReply) Error() string {
return "WRONGTYPE Operation against a key holding the wrong kind of value"
}
// ProtocolErr
// ProtocolErrReply represents meeting unexpected byte during parse requests
type ProtocolErrReply struct {
Msg string
}
// ToBytes marshals redis.Reply
func (r *ProtocolErrReply) ToBytes() []byte {
return []byte("-ERR Protocol error: '" + r.Msg + "'\r\n")
}
func (r *ProtocolErrReply) Error() string {
return "ERR Protocol error: '" + r.Msg
}