[#141] better handling in responseError for non-json error responses

This commit is contained in:
Cory Bennett
2018-02-11 16:46:25 -08:00
parent 4ae760f18f
commit 20a9666fcd
+4 -3
View File
@@ -1,7 +1,6 @@
package jira
import (
"fmt"
"net/http"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
@@ -10,10 +9,12 @@ import (
func responseError(resp *http.Response) error {
results := &jiradata.ErrorCollection{}
if err := readJSON(resp.Body, results); err != nil {
return err
results.Status = resp.StatusCode
results.ErrorMessages = append(results.ErrorMessages, err.Error())
}
if len(results.ErrorMessages) == 0 && len(results.Errors) == 0 {
return fmt.Errorf(resp.Status)
results.Status = resp.StatusCode
results.ErrorMessages = append(results.ErrorMessages, resp.Status)
}
return results
}