Skip to content

Commit

Permalink
Fixes to error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
holovkov committed Jul 31, 2018
1 parent 143cc63 commit bf9413b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type ProcessReply struct {
type HTTPError struct {
Code int
Message string
Details map[string]string
Details map[string]interface{}
}

func (e HTTPError) Error() string {
Expand Down Expand Up @@ -221,7 +221,9 @@ func (s *MangoPay) rawRequest(method, contentType string, uri string, body []byt
HTTPErr.Message = fmt.Sprintf("Response body: '%s'", j)
}
if details, ok := j["errors"]; ok {
HTTPErr.Details = details.(map[string]string)
if HTTPErr.Details, ok = details.(map[string]interface{}); !ok {
HTTPErr.Details = map[string]interface{}{"Error": "Error details returned is not map[string]interface{}"}
}
}
err = HTTPErr
}
Expand Down

0 comments on commit bf9413b

Please sign in to comment.