diff --git a/internal/notif/gotify/client.go b/internal/notif/gotify/client.go index 094ebe7f7..de51bd075 100644 --- a/internal/notif/gotify/client.go +++ b/internal/notif/gotify/client.go @@ -114,9 +114,8 @@ func (c *Client) Send(entry model.NotifEntry) error { ErrorCode int `json:"errorCode"` ErrorDescription string `json:"errorDescription"` } - err := json.NewDecoder(resp.Body).Decode(&errBody) - if err != nil { - return err + if err := json.NewDecoder(resp.Body).Decode(&errBody); err != nil { + return errors.Wrapf(err, "cannot decode JSON error response for HTTP %d %s status", resp.StatusCode, http.StatusText(resp.StatusCode)) } return errors.Errorf("%d %s: %s", errBody.ErrorCode, errBody.Error, errBody.ErrorDescription) } diff --git a/internal/notif/ntfy/client.go b/internal/notif/ntfy/client.go index c664f0de2..dc26f64ae 100644 --- a/internal/notif/ntfy/client.go +++ b/internal/notif/ntfy/client.go @@ -108,9 +108,8 @@ func (c *Client) Send(entry model.NotifEntry) error { ErrorCode int `json:"errorCode"` ErrorDescription string `json:"errorDescription"` } - err := json.NewDecoder(resp.Body).Decode(&errBody) - if err != nil { - return err + if err := json.NewDecoder(resp.Body).Decode(&errBody); err != nil { + return errors.Wrapf(err, "cannot decode JSON error response for HTTP %d %s status", resp.StatusCode, http.StatusText(resp.StatusCode)) } return errors.Errorf("%d %s: %s", errBody.ErrorCode, errBody.Error, errBody.ErrorDescription) } diff --git a/internal/notif/rocketchat/client.go b/internal/notif/rocketchat/client.go index 40d65fc2b..cb20e94e4 100644 --- a/internal/notif/rocketchat/client.go +++ b/internal/notif/rocketchat/client.go @@ -147,14 +147,11 @@ func (c *Client) Send(entry model.NotifEntry) error { Error string `json:"error,omitempty"` ErrorType string `json:"errorType,omitempty"` } - err = json.NewDecoder(resp.Body).Decode(&respBody) - if err == nil { - return err + if err = json.NewDecoder(resp.Body).Decode(&respBody); err != nil { + return errors.Wrapf(err, "cannot decode JSON body response for HTTP %d %s status", resp.StatusCode, http.StatusText(resp.StatusCode)) } - if resp.StatusCode != http.StatusOK { return errors.Errorf("unexpected HTTP error %d: %s", resp.StatusCode, respBody.ErrorType) } - return nil }