diff --git a/jsonapi.go b/jsonapi.go index af347d90f..af693c899 100644 --- a/jsonapi.go +++ b/jsonapi.go @@ -6,6 +6,7 @@ package btcjson import ( "encoding/json" + "errors" "fmt" ) @@ -157,6 +158,7 @@ type ListUnSpentResult struct { type Error struct { Code int `json:"code,omitempty"` Message string `json:"message,omitempty"` + Error error `json:"-"` } // jsonWithArgs takes a command, an id, and an interface which contains an @@ -703,6 +705,7 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) { var jsonErr Error var id interface{} err = json.Unmarshal(objmap["error"], &jsonErr) + jsonErr.Error = errors.New(string(jsonErr.Code) + ": " + jsonErr.Message) if err != nil { err = fmt.Errorf("Error unmarshalling json reply: %v", err) return result, err diff --git a/test_coverage.txt b/test_coverage.txt index 341904580..55d1ee00f 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -1,6 +1,6 @@ github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 100.00% (332/332) -github.com/conformal/btcjson/jsonapi.go ReadResultCmd 100.00% (63/63) +github.com/conformal/btcjson/jsonapi.go ReadResultCmd 100.00% (64/64) github.com/conformal/btcjson/jsonapi.go JSONToAmount 100.00% (15/15) github.com/conformal/btcjson/jsonapi.go JSONGetMethod 100.00% (14/14) github.com/conformal/btcjson/jsonfxns.go jsonRpcSend 100.00% (7/7) @@ -11,5 +11,5 @@ github.com/conformal/btcjson/jsonapi.go IsValidIdType 100.00% (3/3) github.com/conformal/btcjson/jsonapi.go CreateMessage 100.00% (2/2) github.com/conformal/btcjson/jsonapi.go RpcCommand 61.54% (8/13) github.com/conformal/btcjson/jsonapi.go RpcRawCommand 53.33% (8/15) -github.com/conformal/btcjson ------------------- 97.51% (470/482) +github.com/conformal/btcjson ------------------- 97.52% (471/483)