@@ -127,7 +127,7 @@ func (r *Receiver) search(project, issueLabel string) (*jira.Issue, bool, error)
127127 log .V (1 ).Infof ("search: query=%v options=%+v" , query , options )
128128 issues , resp , err := r .client .Issue .Search (query , options )
129129 if err != nil {
130- retry , err := handleJiraError (resp , err )
130+ retry , err := handleJiraError ("Issue.Search" , resp , err )
131131 return nil , retry , err
132132 }
133133 if len (issues ) > 0 {
@@ -145,14 +145,14 @@ func (r *Receiver) search(project, issueLabel string) (*jira.Issue, bool, error)
145145func (r * Receiver ) reopen (issueKey string ) (bool , error ) {
146146 transitions , resp , err := r .client .Issue .GetTransitions (issueKey )
147147 if err != nil {
148- return handleJiraError (resp , err )
148+ return handleJiraError ("Issue.GetTransitions" , resp , err )
149149 }
150150 for _ , t := range transitions {
151151 if t .Name == r .conf .ReopenState {
152152 log .V (1 ).Infof ("reopen: issueKey=%v transitionID=%v" , issueKey , t .ID )
153153 resp , err = r .client .Issue .DoTransition (issueKey , t .ID )
154154 if err != nil {
155- return handleJiraError (resp , err )
155+ return handleJiraError ("Issue.DoTransition" , resp , err )
156156 }
157157 log .V (1 ).Infof (" done" )
158158 return false , nil
@@ -165,20 +165,25 @@ func (r *Receiver) create(issue *jira.Issue) (bool, error) {
165165 log .V (1 ).Infof ("create: issue=%v" , * issue )
166166 issue , resp , err := r .client .Issue .Create (issue )
167167 if err != nil {
168- return handleJiraError (resp , err )
168+ return handleJiraError ("Issue.Create" , resp , err )
169169 }
170170
171171 log .V (1 ).Infof (" done: key=%s ID=%s" , issue .Key , issue .ID )
172172 return false , nil
173173}
174174
175- func handleJiraError (resp * jira.Response , err error ) (bool , error ) {
176- log .V (1 ).Infof ("handleJiraError: err=%s, req=%s" , err , resp .Request .URL )
175+ func handleJiraError (api string , resp * jira.Response , err error ) (bool , error ) {
176+ if resp == nil || resp .Request == nil {
177+ log .V (1 ).Infof ("handleJiraError: api=%s, err=%s" , api , err )
178+ } else {
179+ log .V (1 ).Infof ("handleJiraError: api=%s, url=%s, err=%s" , api , resp .Request .URL , err )
180+ }
181+
177182 if resp != nil && resp .StatusCode / 100 != 2 {
178183 retry := resp .StatusCode == 500 || resp .StatusCode == 503
179184 body , _ := ioutil .ReadAll (resp .Body )
180185 // go-jira error message is not particularly helpful, replace it
181186 return retry , fmt .Errorf ("JIRA request %s returned status %s, body %q" , resp .Request .URL , resp .Status , string (body ))
182187 }
183- return false , err
188+ return false , fmt . Errorf ( "JIRA request %s failed: %s" , api , err )
184189}
0 commit comments