mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33:28 +02:00
if response is 400, check json for errorMessages and log them
This commit is contained in:
+12
-2
@@ -116,9 +116,19 @@ func runTemplate(templateContent string, data interface{}, out io.Writer) error
|
||||
func responseToJson(resp *http.Response, err error) (interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return jsonDecode(resp.Body), nil
|
||||
}
|
||||
|
||||
data := jsonDecode(resp.Body)
|
||||
if resp.StatusCode == 400 {
|
||||
if val, ok := data.(map[string]interface{})["errorMessages"]; ok {
|
||||
for _,errMsg := range val.([]interface{}) {
|
||||
log.Error("%s", errMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func jsonDecode(io io.Reader) interface{} {
|
||||
|
||||
Reference in New Issue
Block a user