notify/wechat: adjust result check sequence. (#2044)

Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
johncming 2019-09-23 15:31:57 +08:00 committed by Simon Pasquier
parent bc6dd0dd46
commit 7d21f5a5a9
1 changed files with 4 additions and 4 deletions

View File

@ -171,16 +171,16 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
}
defer notify.Drain(resp)
if resp.StatusCode != 200 {
return true, fmt.Errorf("unexpected status code %v", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return true, err
}
level.Debug(n.logger).Log("response", string(body), "incident", key)
if resp.StatusCode != 200 {
return true, fmt.Errorf("unexpected status code %v", resp.StatusCode)
}
var weResp weChatResponse
if err := json.Unmarshal(body, &weResp); err != nil {
return true, err