1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-04 04:55:23 +02:00

Update Jira client library to latest release

Related to #308
This commit is contained in:
HarveyKandola 2019-08-27 17:16:06 +01:00
parent 5b72da037c
commit 0419f3b7b3
18 changed files with 1734 additions and 1274 deletions

View file

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"strings"
"github.com/pkg/errors"
)
@ -28,12 +29,19 @@ func NewJiraError(resp *Response, httpError error) error {
if err != nil {
return errors.Wrap(err, httpError.Error())
}
jerr := Error{HTTPError: httpError}
err = json.Unmarshal(body, &jerr)
if err != nil {
httpError = errors.Wrap(errors.New("Could not parse JSON"), httpError.Error())
return errors.Wrap(err, httpError.Error())
contentType := resp.Header.Get("Content-Type")
if strings.HasPrefix(contentType, "application/json") {
err = json.Unmarshal(body, &jerr)
if err != nil {
httpError = errors.Wrap(errors.New("Could not parse JSON"), httpError.Error())
return errors.Wrap(err, httpError.Error())
}
} else {
if httpError == nil {
return fmt.Errorf("Got Response Status %s:%s", resp.Status, string(body))
}
return errors.Wrap(httpError, fmt.Sprintf("%s: %s", resp.Status, string(body)))
}
return &jerr