// errorHandler parses a non 2xx error response into an error
errorHandler parses a non 2xx error response into an error
// errorHandler parses a non 2xx error response into an error
func errorHandler(resp *http.Response) error {
	body, err := rest.ReadBody(resp)
	if err != nil {
		return errors.Wrap(err, "error when trying to read error from body")
	}
	errResponse := new(api.Error)
	err = xml.Unmarshal(body, &errResponse)
	if err != nil {
		errResponse.Message = strings.TrimSpace(string(body))
	}
	errResponse.Status = resp.Status
	errResponse.StatusCode = resp.StatusCode
	return errResponse
}
func errorHandler ( resp * http . Response ) error { body , err := rest . ReadBody ( resp ) if err != nil { return errors . Wrap ( err , " " ) } errResponse := new ( api . Error ) err = xml . Unmarshal ( body , & errResponse ) if err != nil { errResponse . Message = strings . TrimSpace ( string ( body ) ) } errResponse . Status = resp . Status errResponse . StatusCode = resp . StatusCode return errResponse }
errorHandler parses a non 2xx error response into an error
errorHandler parses a non 2xx error response into an error
// Decode error response // set the Message to be the body if can't parse the XML