diff options
author | Quang-Minh Nguyen <qmnguyen@gitlab.com> | 2023-03-16 06:00:07 +0300 |
---|---|---|
committer | Quang-Minh Nguyen <qmnguyen@gitlab.com> | 2023-03-16 06:00:07 +0300 |
commit | dac5f9dc8a12671ccafc79c3d1681f6e6f131ed4 (patch) | |
tree | ea3eea9886fc58dd48b893ef576ed82075a6eaef /internal/bootstrap | |
parent | 936640076881092ad60202823f2dc81828aa4b6d (diff) |
lint: Fix discouraged error wrapping verb
We encourage wrapping error with %w when constructing a new error. The
new error contains the original error so that it is able to be unwrapped
later. This commit converts all error wrapping to %w.
Diffstat (limited to 'internal/bootstrap')
-rw-r--r-- | internal/bootstrap/bootstrap.go | 2 | ||||
-rw-r--r-- | internal/bootstrap/bootstrap_test.go | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go index a0251fee0..6a2473390 100644 --- a/internal/bootstrap/bootstrap.go +++ b/internal/bootstrap/bootstrap.go @@ -183,7 +183,7 @@ func (b *Bootstrap) Wait(gracePeriodTicker helper.Ticker, stopAction func()) err // we set a grace period and then we force a termination. waitError := b.waitGracePeriod(gracePeriodTicker, immediateShutdown, stopAction) - err = fmt.Errorf("graceful upgrade: %v", waitError) + err = fmt.Errorf("graceful upgrade: %w", waitError) case s := <-immediateShutdown: err = fmt.Errorf("received signal %q", s) b.upgrader.Stop() diff --git a/internal/bootstrap/bootstrap_test.go b/internal/bootstrap/bootstrap_test.go index d69ca5156..7dfa7f053 100644 --- a/internal/bootstrap/bootstrap_test.go +++ b/internal/bootstrap/bootstrap_test.go @@ -148,7 +148,7 @@ func TestBootstrap_gracefulTerminationStuck(t *testing.T) { // terminate and thus the graceful termination will be stuck. <-ctx.Done() }) - require.Equal(t, fmt.Errorf("graceful upgrade: grace period expired"), err) + require.Equal(t, fmt.Errorf("graceful upgrade: %w", fmt.Errorf("grace period expired")), err) cancel() <-doneCh @@ -172,7 +172,7 @@ func TestBootstrap_gracefulTerminationWithSignals(t *testing.T) { // signal was processed. <-ctx.Done() }) - require.Equal(t, fmt.Errorf("graceful upgrade: force shutdown"), err) + require.Equal(t, fmt.Errorf("graceful upgrade: %w", fmt.Errorf("force shutdown")), err) cancel() <-doneCh @@ -201,7 +201,7 @@ func TestBootstrap_gracefulTerminationTimeoutWithListenerError(t *testing.T) { // terminate. <-ctx.Done() }) - require.Equal(t, fmt.Errorf("graceful upgrade: grace period expired"), err) + require.Equal(t, fmt.Errorf("graceful upgrade: %w", fmt.Errorf("grace period expired")), err) cancel() <-doneCh @@ -213,7 +213,7 @@ func TestBootstrap_gracefulTermination(t *testing.T) { b, upgrader, _ := setup(t, ctx) require.Equal(t, - fmt.Errorf("graceful upgrade: completed"), + fmt.Errorf("graceful upgrade: %w", fmt.Errorf("completed")), performUpgrade(t, b, upgrader, helper.NewManualTicker(), nil, nil), ) } |