Closed billglover closed 6 years ago
If we return an empty string inside the conditional we prevent the panic, but reveal the fact that the client isn't able to parse the error response from the server.
var tuResp *savingsGoalTransferResponse
resp, err := c.Do(ctx, req, &tuResp)
if err != nil {
return "", resp, err
}
return tuResp.UID, resp, nil
Results in the following response:
API returned an error but client was unable to parse the detail: json: cannot unmarshal array into Go value of type starling.ErrorDetail
If the server responds with a bad request, the following code will result in a panic as it tries to access UID on a nilb savingsGoalTransferResponse.