Correct error handling on createMarshalledReply.

This commit correctly sets the error in the marhsalled reply if it is
already a *btcjson.Error.  Previously it would only set the error if it
was not of that type which led to some RPC results showing no error when
they actually had one.
This commit is contained in:
Dave Collins 2014-04-25 02:51:03 -05:00
parent bdaa5f7f8d
commit 27082ace79

View file

@ -832,10 +832,12 @@ type wsResponse struct {
func createMarshalledReply(id, result interface{}, replyErr error) ([]byte, error) {
var jsonErr *btcjson.Error
if replyErr != nil {
if jErr, ok := replyErr.(*btcjson.Error); !ok {
if jErr, ok := replyErr.(*btcjson.Error); ok {
jsonErr = jErr
} else {
jsonErr = &btcjson.Error{
Code: btcjson.ErrInternal.Code,
Message: jErr.Error(),
Message: replyErr.Error(),
}
}
}