From 7d21f5a5a92134108b984398f94b35f78d4d8da7 Mon Sep 17 00:00:00 2001 From: johncming Date: Mon, 23 Sep 2019 15:31:57 +0800 Subject: [PATCH] notify/wechat: adjust result check sequence. (#2044) Signed-off-by: johncming --- notify/wechat/wechat.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notify/wechat/wechat.go b/notify/wechat/wechat.go index c3e5c726..17c15603 100644 --- a/notify/wechat/wechat.go +++ b/notify/wechat/wechat.go @@ -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