modify error msg

This commit is contained in:
wenyekui 2014-07-24 11:41:53 +08:00
parent a6a760880d
commit 3f3ca8da63
2 changed files with 12 additions and 5 deletions

View File

@ -8,13 +8,13 @@ import (
) )
const ( const (
ERR_ARGUMENT_FORMAT = "ERR wrong number of arguments for '%s' command" ERR_ARGUMENT_FORMAT = "wrong number of arguments for '%s' command"
MSG_OK = "OK" MSG_OK = "OK"
) )
var ( var (
ErrValue = errors.New("ERR value is not an integer or out of range") ErrValue = errors.New("value is not an integer or out of range")
ErrSyntax = errors.New("ERR syntax error") ErrSyntax = errors.New("syntax error")
) )
type commondFunc func(*ledis.DB, ...string) (interface{}, error) type commondFunc func(*ledis.DB, ...string) (interface{}, error)

View File

@ -288,8 +288,15 @@ func zrangeGeneric(db *ledis.DB, reverse bool, args ...string) (interface{}, err
args = args[3:] args = args[3:]
var withScores bool = false var withScores bool = false
if len(args) > 0 && strings.ToLower(args[0]) == "withscores" { if len(args) > 0 {
if len(args) != 1 {
return nil, ErrSyntax
}
if strings.ToLower(args[0]) == "withscores" {
withScores = true withScores = true
} else {
return nil, ErrSyntax
}
} }
if datas, err := db.ZRangeGeneric(key, start, stop, reverse); err != nil { if datas, err := db.ZRangeGeneric(key, start, stop, reverse); err != nil {