From 27082ace795217e4ff7dd3ed656ea923917b63cb Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 25 Apr 2014 02:51:03 -0500 Subject: [PATCH] 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. --- rpcwebsocket.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rpcwebsocket.go b/rpcwebsocket.go index 9b463dd9..7ceb4621 100644 --- a/rpcwebsocket.go +++ b/rpcwebsocket.go @@ -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(), } } }