diff --git a/notify/rocketchat/rocketchat.go b/notify/rocketchat/rocketchat.go index b0fc881200..dbb1b51e95 100644 --- a/notify/rocketchat/rocketchat.go +++ b/notify/rocketchat/rocketchat.go @@ -23,7 +23,6 @@ import ( "os" "strings" - "github.com/pkg/errors" commoncfg "github.com/prometheus/common/config" "github.com/prometheus/alertmanager/template" @@ -224,14 +223,14 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error) // classify them as retriable or not. retry, err := n.retrier.Check(resp.StatusCode, resp.Body) if err != nil { - err = errors.Wrap(err, fmt.Sprintf("channel %q", body.Channel)) + err = fmt.Errorf("%w: channel %q", err, body.Channel) return retry, notify.NewErrorWithReason(notify.GetFailureReasonFromStatusCode(resp.StatusCode), err) } // Rocketchat web API might return errors with a 200 response code. retry, err = checkResponseError(resp) if err != nil { - err = errors.Wrap(err, fmt.Sprintf("channel %q", body.Channel)) + err = fmt.Errorf("%w: channel %q", err, body.Channel) return retry, notify.NewErrorWithReason(notify.ClientErrorReason, err) } @@ -242,7 +241,7 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error) func checkResponseError(resp *http.Response) (bool, error) { body, err := io.ReadAll(resp.Body) if err != nil { - return true, errors.Wrap(err, "could not read response body") + return true, fmt.Errorf("%w: could not read response body: ", err) } return checkJSONResponseError(body) @@ -258,7 +257,7 @@ func checkJSONResponseError(body []byte) (bool, error) { var data response if err := json.Unmarshal(body, &data); err != nil { - return true, errors.Wrapf(err, "could not unmarshal JSON response %q", string(body)) + return true, fmt.Errorf("%w: could not unmarshal JSON response %q", err, string(body)) } if !data.Success { return false, fmt.Errorf("error response from Rocketchat: %s", data.Error)