diff --git a/api/controller/contact.go b/api/controller/contact.go index eb54d79fe..df9660598 100644 --- a/api/controller/contact.go +++ b/api/controller/contact.go @@ -97,7 +97,7 @@ func UpdateContact(dataBase moira.Database, contactDTO dto.Contact, contactData // RemoveContact deletes notification contact for current user and remove contactID from all subscriptions func RemoveContact(database moira.Database, contactID string, userLogin string, teamID string) *api.ErrorResponse { //nolint:gocyclo - var subscriptionIDs []string + subscriptionIDs := make([]string, 0) if userLogin != "" { userSubscriptionIDs, err := database.GetUserSubscriptionIDs(userLogin) if err != nil { diff --git a/filter/connection/listening.go b/filter/connection/listening.go index 19e5d5910..f9a1a37ee 100644 --- a/filter/connection/listening.go +++ b/filter/connection/listening.go @@ -62,7 +62,7 @@ func (listener *MetricsListener) Listen() chan []byte { conn, err := listener.listener.Accept() if nil != err { var opErr *net.OpError - if ok := errors.Is(err, opErr); ok && opErr.Timeout() { + if ok := errors.As(err, &opErr); ok && opErr.Timeout() { continue } listener.logger.Info(). diff --git a/index/index_test.go b/index/index_test.go index 7d654df92..bf1fea55c 100644 --- a/index/index_test.go +++ b/index/index_test.go @@ -47,7 +47,7 @@ func TestGetTriggerChecksWithRetries(t *testing.T) { dataBase.EXPECT().GetTriggerChecks(randomBatch).Return(nil, expectedError).Times(3) actualData, actualError := index.getTriggerChecksWithRetries(randomBatch) So(actualData, ShouldBeEmpty) - So(actualError, ShouldResemble, fmt.Errorf("cannot get trigger checks from DB after 3 tries, last error: %w", expectedError)) + So(actualError.Error(), ShouldResemble, fmt.Sprintf("cannot get trigger checks from DB after 3 tries, last error: %v", expectedError)) }) } diff --git a/notifier/plotting.go b/notifier/plotting.go index 9992898f5..d537e0ae3 100644 --- a/notifier/plotting.go +++ b/notifier/plotting.go @@ -169,7 +169,7 @@ func fetchAvailableSeries(metricsSource metricSource.MetricSource, target string return realtimeFetchResult.GetMetricsData(), nil } var errFailedWithPanic local.ErrEvaluateTargetFailedWithPanic - if ok := errors.Is(realtimeErr, errFailedWithPanic); ok { + if ok := errors.As(realtimeErr, &errFailedWithPanic); ok { fetchResult, err := metricsSource.Fetch(target, from, to, false) if err != nil { return nil, errFetchAvailableSeriesFailed{realtimeErr: errFailedWithPanic.Error(), storedErr: err.Error()} diff --git a/notifier/plotting_test.go b/notifier/plotting_test.go index eb5795b3b..6e0abcd14 100644 --- a/notifier/plotting_test.go +++ b/notifier/plotting_test.go @@ -224,7 +224,7 @@ func TestFetchAvailableSeries(t *testing.T) { Convey("with error ErrEvaluateTargetFailedWithPanic and error again", func() { var err error = local.ErrEvaluateTargetFailedWithPanic{} - var secondErr = errors.New("Test error") + var secondErr = errors.New("test error") gomock.InOrder( source.EXPECT().Fetch("testTarget", int64(17), int64(67), true).Return(nil, err).Times(1), source.EXPECT().Fetch("testTarget", int64(17), int64(67), false).Return(nil, secondErr).Times(1), @@ -234,7 +234,7 @@ func TestFetchAvailableSeries(t *testing.T) { }) Convey("with unknown error", func() { - var err error = errors.New("Test error") + var err = errors.New("test error") gomock.InOrder( source.EXPECT().Fetch("testTarget", int64(17), int64(67), true).Return(nil, err).Times(1), ) diff --git a/senders/telegram/send.go b/senders/telegram/send.go index 8d50759d7..fa0e2e59a 100644 --- a/senders/telegram/send.go +++ b/senders/telegram/send.go @@ -2,10 +2,11 @@ package telegram import ( "bytes" - "errors" "fmt" "strings" + "errors" + "gopkg.in/tucnak/telebot.v2" "github.com/moira-alert/moira" @@ -147,8 +148,9 @@ func checkBrokenContactError(logger moira.Logger, err error) error { if err == nil { return nil } + var e *telebot.APIError - if ok := errors.Is(err, e); ok { + if ok := errors.As(err, &e); ok { logger.Debug(). Int("code", e.Code). String("msg", e.Message).