capitalize RpcError
This commit is contained in:
parent
2252071866
commit
e36c79f713
|
@ -422,8 +422,8 @@ func (c *WSClient) readRoutine() {
|
||||||
c.ErrorsCh <- err
|
c.ErrorsCh <- err
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if response.Error != "" {
|
if response.Error != nil {
|
||||||
c.ErrorsCh <- errors.Errorf(response.Error)
|
c.ErrorsCh <- errors.New(response.Error.Message)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.Logger.Info("got response", "resp", response.Result)
|
c.Logger.Info("got response", "resp", response.Result)
|
||||||
|
|
|
@ -54,7 +54,7 @@ func ArrayToRequest(id string, method string, params []interface{}) (RPCRequest,
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
// RESPONSE
|
// RESPONSE
|
||||||
|
|
||||||
type RpcError struct {
|
type RPCError struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Data string `json:"data,omitempty"`
|
Data string `json:"data,omitempty"`
|
||||||
|
@ -64,7 +64,7 @@ type RPCResponse struct {
|
||||||
JSONRPC string `json:"jsonrpc"`
|
JSONRPC string `json:"jsonrpc"`
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
Result *json.RawMessage `json:"result,omitempty"`
|
Result *json.RawMessage `json:"result,omitempty"`
|
||||||
Error *RpcError `json:"error,omitempty"`
|
Error *RPCError `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRPCSuccessResponse(id string, res interface{}) RPCResponse {
|
func NewRPCSuccessResponse(id string, res interface{}) RPCResponse {
|
||||||
|
@ -87,12 +87,12 @@ func NewRPCErrorResponse(id string, code int, msg string, data string) RPCRespon
|
||||||
return RPCResponse{
|
return RPCResponse{
|
||||||
JSONRPC: "2.0",
|
JSONRPC: "2.0",
|
||||||
ID: id,
|
ID: id,
|
||||||
Error: &RpcError{Code: code, Message: msg, Data: data},
|
Error: &RPCError{Code: code, Message: msg, Data: data},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resp RPCResponse) String() string {
|
func (resp RPCResponse) String() string {
|
||||||
if resp.Error == "" {
|
if resp.Error == nil {
|
||||||
return fmt.Sprintf("[%s %v]", resp.ID, resp.Result)
|
return fmt.Sprintf("[%s %v]", resp.ID, resp.Result)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf("[%s %s]", resp.ID, resp.Error)
|
return fmt.Sprintf("[%s %s]", resp.ID, resp.Error)
|
||||||
|
|
Loading…
Reference in New Issue