Skip to content

Commit

Permalink
test: resolve potential panic
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Feb 14, 2022
1 parent 98ee300 commit d44af28
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/go/pkg/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ func SDKExitOnError(err error, res *http.Response) {
if err == nil {
return
}
body, _ := json.MarshalIndent(json.RawMessage(x.MustReadAll(res.Body)), "", " ")
var body []byte
if res != nil {
body, _ = json.MarshalIndent(json.RawMessage(x.MustReadAll(res.Body)), "", " ")
}
out, _ := json.MarshalIndent(err, "", " ")
fmt.Printf("%s\n\nAn error occurred: %+v\nbody: %s\n", out, err, body)
os.Exit(1)
Expand Down

0 comments on commit d44af28

Please sign in to comment.