From e36c79f7137769af5ce500ab164d94ddc347d838 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 18 Jul 2017 13:08:51 +0300 Subject: [PATCH] capitalize RpcError --- rpc/lib/client/ws_client.go | 4 ++-- rpc/lib/types/types.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rpc/lib/client/ws_client.go b/rpc/lib/client/ws_client.go index f56c45e9..7bf3fc2a 100644 --- a/rpc/lib/client/ws_client.go +++ b/rpc/lib/client/ws_client.go @@ -422,8 +422,8 @@ func (c *WSClient) readRoutine() { c.ErrorsCh <- err continue } - if response.Error != "" { - c.ErrorsCh <- errors.Errorf(response.Error) + if response.Error != nil { + c.ErrorsCh <- errors.New(response.Error.Message) continue } c.Logger.Info("got response", "resp", response.Result) diff --git a/rpc/lib/types/types.go b/rpc/lib/types/types.go index b649d1b9..8d71d6f2 100644 --- a/rpc/lib/types/types.go +++ b/rpc/lib/types/types.go @@ -54,7 +54,7 @@ func ArrayToRequest(id string, method string, params []interface{}) (RPCRequest, //---------------------------------------- // RESPONSE -type RpcError struct { +type RPCError struct { Code int `json:"code"` Message string `json:"message"` Data string `json:"data,omitempty"` @@ -64,7 +64,7 @@ type RPCResponse struct { JSONRPC string `json:"jsonrpc"` ID string `json:"id,omitempty"` Result *json.RawMessage `json:"result,omitempty"` - Error *RpcError `json:"error,omitempty"` + Error *RPCError `json:"error,omitempty"` } func NewRPCSuccessResponse(id string, res interface{}) RPCResponse { @@ -87,12 +87,12 @@ func NewRPCErrorResponse(id string, code int, msg string, data string) RPCRespon return RPCResponse{ JSONRPC: "2.0", ID: id, - Error: &RpcError{Code: code, Message: msg, Data: data}, + Error: &RPCError{Code: code, Message: msg, Data: data}, } } func (resp RPCResponse) String() string { - if resp.Error == "" { + if resp.Error == nil { return fmt.Sprintf("[%s %v]", resp.ID, resp.Result) } else { return fmt.Sprintf("[%s %s]", resp.ID, resp.Error)