Skip to content

Commit

Permalink
rerun when relay response error (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ylsGit authored Jun 27, 2024
1 parent de5e5da commit e6a2bde
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion jsonrpc/client/client_xlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ func JSONRPCRelay(url string, request types.Request) (types.Response, error) {
defer httpRes.Body.Close()

if httpRes.StatusCode != http.StatusOK {
return types.Response{}, fmt.Errorf("%v - %v", httpRes.StatusCode, string(resBody))
return types.Response{}, fmt.Errorf("http error: %v - %v", httpRes.StatusCode, string(resBody))
}

var res types.Response
err = json.Unmarshal(resBody, &res)
if err != nil {
return types.Response{}, err
}
if res.Error != nil {
return types.Response{}, fmt.Errorf("response error: %v - %v", res.Error.Code, res.Error.Message)
}
return res, nil
}

0 comments on commit e6a2bde

Please sign in to comment.