From 5d84e46b4e64c9f6b351199a39ec470496b6b3a5 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Tue, 2 Nov 2021 16:38:39 -0400 Subject: [PATCH] kv: fix improperly wrapped errors I'm working on a linter that detects errors that are not wrapped correctly, and it discovered these. Release note: None --- pkg/kv/kvclient/kvcoord/dist_sender.go | 2 +- pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go | 2 +- pkg/kv/kvserver/client_merge_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/kv/kvclient/kvcoord/dist_sender.go b/pkg/kv/kvclient/kvcoord/dist_sender.go index ecca32f9a73c..0ec5f1c339b8 100644 --- a/pkg/kv/kvclient/kvcoord/dist_sender.go +++ b/pkg/kv/kvclient/kvcoord/dist_sender.go @@ -2198,7 +2198,7 @@ func skipStaleReplicas( if !routing.Valid() { return noMoreReplicasErr( ambiguousError, - errors.Newf("routing information detected to be stale; lastErr: %s", lastErr)) + errors.Wrap(lastErr, "routing information detected to be stale")) } for { diff --git a/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go b/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go index aeaa961a6998..3c6bf1da8c75 100644 --- a/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go +++ b/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go @@ -289,7 +289,7 @@ func verifyCleanup(key roachpb.Key, eng storage.Engine, t *testing.T, coords ... //lint:ignore SA1019 historical usage of deprecated eng.MVCCGetProto is OK ok, _, _, err := eng.MVCCGetProto(storage.MakeMVCCMetadataKey(key), meta) if err != nil { - return fmt.Errorf("error getting MVCC metadata: %s", err) + return errors.Wrap(err, "error getting MVCC metadata") } if ok && meta.Txn != nil { return fmt.Errorf("found unexpected write intent: %s", meta) diff --git a/pkg/kv/kvserver/client_merge_test.go b/pkg/kv/kvserver/client_merge_test.go index fad033662d11..147ab02780fc 100644 --- a/pkg/kv/kvserver/client_merge_test.go +++ b/pkg/kv/kvserver/client_merge_test.go @@ -5017,7 +5017,7 @@ func setupClusterWithSubsumedRange( newDesc, err = tc.AddVoters(desc.StartKey.AsRawKey(), tc.Target(1)) if kv.IsExpectedRelocateError(err) { // Retry. - return errors.Newf("ChangeReplicas: received error %s", err) + return errors.Wrap(err, "ChangeReplicas received error") } return nil })