Skip to content

Handle RPC Error properly #59

Open
@cubismic

Description

@cubismic

Currently, if RPC error occurs, the error message just gives
unexpected end of JSON input
Because the error format provided by the rpc server is as follows:

{
  code: -32032,
  message: 'Not Enough Balance',
  data: 'InsufficientBalance { address: Address(~~), balance: ~, cost: ~ }'
}

unexpected end of JSON input comes from line 75.
(body has the error message in byte slice)

resp, err := client.httpClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
body, readerr := ioutil.ReadAll(resp.Body)
if readerr != nil {
return readerr
}
var outerResult Result
if err := json.Unmarshal(body, &outerResult); err != nil {
return err
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions