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 |
|
} |