Skip to content

Commit

Permalink
[#141] better handling in responseError for non-json error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Feb 12, 2018
1 parent 4ae760f commit 20a9666
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions error.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package jira

import (
"fmt"
"net/http"

"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
Expand All @@ -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
}

0 comments on commit 20a9666

Please sign in to comment.