Commit ef0826ac authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

fix(commands/err)

I didn't know there were dragons here.

When casting errors we've gotta be careful. Apparently both values and
pointers satisfy the error interface. Type checking for one doesn't
catch the other.

cc @whyrusleeping @mappum @jbenet

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent ca2828f3
......@@ -103,11 +103,12 @@ func (c *Command) Call(req Request) Response {
if err != nil {
// if returned error is a commands.Error, use its error code
// otherwise, just default the code to ErrNormal
var e Error
e, ok := err.(Error)
if ok {
switch e := err.(type) {
case *Error:
res.SetError(e, e.Code)
} else {
case Error:
res.SetError(e, e.Code)
default:
res.SetError(err, ErrNormal)
}
return res
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment