forked from mirror/ledisdb
fix error messages to be redis compliant (#293)
This commit is contained in:
parent
80ea7b8bca
commit
5835ab9b2b
|
@ -228,7 +228,6 @@ func newWriterRESP(conn net.Conn, size int) *respWriter {
|
||||||
func (w *respWriter) writeError(err error) {
|
func (w *respWriter) writeError(err error) {
|
||||||
w.buff.Write(hack.Slice("-"))
|
w.buff.Write(hack.Slice("-"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.buff.WriteByte(' ')
|
|
||||||
w.buff.Write(hack.Slice(err.Error()))
|
w.buff.Write(hack.Slice(err.Error()))
|
||||||
}
|
}
|
||||||
w.buff.Write(Delims)
|
w.buff.Write(Delims)
|
||||||
|
|
|
@ -14,8 +14,7 @@ func TestRespWriter(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
v: errors.New("Some error"),
|
v: errors.New("Some error"),
|
||||||
//e: "-Some error\r\n", // as described at http://redis.io/topics/protocol
|
e: "-Some error\r\n", // as described at http://redis.io/topics/protocol
|
||||||
e: "- Some error\r\n", // actual
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
v: "Some status",
|
v: "Some status",
|
||||||
|
@ -43,7 +42,6 @@ func TestRespWriter(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
v: []interface{}{[]interface{}{int64(1), int64(2), int64(3)}, []interface{}{"Foo", errors.New("Bar")}},
|
v: []interface{}{[]interface{}{int64(1), int64(2), int64(3)}, []interface{}{"Foo", errors.New("Bar")}},
|
||||||
//e: "*2\r\n*3\r\n:1\r\n:2\r\n:3\r\n*2\r\n+Foo\r\n-Bar\r\n",
|
|
||||||
e: "*2\r\n*3\r\n:1\r\n:2\r\n:3\r\n*2\r\n+Foo\r\n-Bar\r\n",
|
e: "*2\r\n*3\r\n:1\r\n:2\r\n:3\r\n*2\r\n+Foo\r\n-Bar\r\n",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
@ -68,7 +66,7 @@ func TestRespWriter(t *testing.T) {
|
||||||
}
|
}
|
||||||
w.flush()
|
w.flush()
|
||||||
if b.String() != fixture.e {
|
if b.String() != fixture.e {
|
||||||
t.Errorf("respWriter, actual: %v, expected: %v", []byte(b.String()), []byte(fixture.e))
|
t.Errorf("respWriter, actual: %q, expected: %q", b.String(), fixture.e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package server
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/siddontang/go/hack"
|
"github.com/siddontang/go/hack"
|
||||||
|
@ -70,7 +71,7 @@ func evalGenericCommand(c *client, evalSha1 bool) (err error) {
|
||||||
|
|
||||||
if global.Type() == lua.LTNil {
|
if global.Type() == lua.LTNil {
|
||||||
if evalSha1 {
|
if evalSha1 {
|
||||||
return fmt.Errorf("missing %s script", key)
|
return errors.New("NOSCRIPT no matching script, please use EVAL")
|
||||||
}
|
}
|
||||||
|
|
||||||
val, err := l.LoadString(hack.String(c.args[0]))
|
val, err := l.LoadString(hack.String(c.args[0]))
|
||||||
|
|
Loading…
Reference in New Issue