Type mismatch errors are now prefixed with WRONGTYPE.

So instead to reply with a generic error like:

-ERR ... wrong kind of value ...

now it replies with:

-WRONGTYPE ... wrong kind of value ...

This makes this particular error easy to check without resorting to
(fragile) pattern matching of the error string (however the error string
used to be consistent already).

Client libraries should return a specific exeption type for this error.

Most of the commit is about fixing unit tests.
This commit is contained in:
antirez
2012-11-06 20:25:34 +01:00
parent 06851a93de
commit c4b0b6854e
5 changed files with 26 additions and 26 deletions

View File

@ -143,7 +143,7 @@ start_server {tags {"basic"}} {
catch {r incr mylist} err
r rpop mylist
format $err
} {ERR*}
} {WRONGTYPE*}
test {DECRBY over 32bit value with over 32bit increment, negative res} {
r set novar 17179869184
@ -201,7 +201,7 @@ start_server {tags {"basic"}} {
catch {r incrbyfloat mylist 1.0} err
r del mylist
format $err
} {ERR*kind*}
} {WRONGTYPE*}
test {INCRBYFLOAT does not allow NaN or Infinity} {
r set foo 0
@ -531,7 +531,7 @@ start_server {tags {"basic"}} {
test "SETBIT against key with wrong type" {
r del mykey
r lpush mykey "foo"
assert_error "*wrong kind*" {r setbit mykey 0 1}
assert_error "WRONGTYPE*" {r setbit mykey 0 1}
}
test "SETBIT with out of range bit offset" {
@ -665,7 +665,7 @@ start_server {tags {"basic"}} {
test "SETRANGE against key with wrong type" {
r del mykey
r lpush mykey "foo"
assert_error "*wrong kind*" {r setrange mykey 0 bar}
assert_error "WRONGTYPE*" {r setrange mykey 0 bar}
}
test "SETRANGE with out of range offset" {