mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 21:43:32 +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) {
|
func responseToJson(resp *http.Response, err error) (interface{}, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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{} {
|
func jsonDecode(io io.Reader) interface{} {
|
||||||
|
|||||||
Reference in New Issue
Block a user