Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added response logging for Jira API errors #59

Merged
merged 1 commit into from
May 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions server/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"

Expand Down Expand Up @@ -75,12 +76,17 @@ func httpAPICreateIssue(ji Instance, w http.ResponseWriter, r *http.Request) (in
}
}

created, _, err := jiraClient.Issue.Create(&jira.Issue{
created, resp, err := jiraClient.Issue.Create(&jira.Issue{
Fields: &create.Fields,
})
if err != nil {
return http.StatusInternalServerError,
errors.WithMessage(err, "failed to create the issue, postId: "+create.PostId)
message := "failed to create the issue, postId: " + create.PostId
if resp != nil {
bb, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
message += ", details:" + string(bb)
}
return http.StatusInternalServerError, errors.WithMessage(err, message)
}

// Upload file attachments in the background
Expand Down Expand Up @@ -158,12 +164,18 @@ func httpAPIGetCreateIssueMetadata(ji Instance, w http.ResponseWriter, r *http.R
return http.StatusInternalServerError, err
}

cimd, _, err := jiraClient.Issue.GetCreateMetaWithOptions(&jira.GetQueryOptions{
cimd, resp, err := jiraClient.Issue.GetCreateMetaWithOptions(&jira.GetQueryOptions{
Expand: "projects.issuetypes.fields",
})
if err != nil {
message := "failed to get CreateIssue metadata"
if resp != nil {
bb, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
message += ", details:" + string(bb)
}
return http.StatusInternalServerError,
errors.WithMessage(err, "failed to get CreateIssue mettadata")
errors.WithMessage(err, message)
}

w.Header().Set("Content-Type", "application/json")
Expand Down