Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treat non-JSON responses well #24

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

joesis
Copy link

@joesis joesis commented Oct 24, 2019

No description provided.

mandrill.go Outdated
@@ -321,6 +322,9 @@ func (c *Client) sendApiRequest(data interface{}, path string) (body []byte, err
if resp.StatusCode >= 400 {
resError := &Error{}
err = json.Unmarshal(body, resError)
if err != nil {
return nil, fmt.Errorf("HTTP %v: %v", resp.StatusCode, string(body))
}
return body, resError
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the http response is not in JSON format, resError would be empty. In such case it's better to pass the status and message back to the caller.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.4%) to 95.522% when pulling 7094d8b on getlantern:master into 1775dd4 on keighl:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants