diff --git a/src/ctl/service/r2/store/kv/store.go b/src/ctl/service/r2/store/kv/store.go index 0af7b420c2..b3486396f6 100644 --- a/src/ctl/service/r2/store/kv/store.go +++ b/src/ctl/service/r2/store/kv/store.go @@ -469,8 +469,8 @@ func handleUpstreamError(err error) error { } // If this is a contained error, extracts the inner error. - if containedErr, ok := err.(xerrors.ContainedError); ok { - err = containedErr.InnerError() + if e := xerrors.InnerError(err); e != nil { + err = e } switch err.(type) { diff --git a/src/metrics/rules/ruleset_test.go b/src/metrics/rules/ruleset_test.go index b1339ccebe..322534e8c6 100644 --- a/src/metrics/rules/ruleset_test.go +++ b/src/metrics/rules/ruleset_test.go @@ -571,10 +571,9 @@ func TestRuleSetAddMappingRuleDuplicateRule(t *testing.T) { newID, err := rs.AddMappingRule(view, helper.NewUpdateMetadata(nowNanos, testUser)) require.Error(t, err) require.Empty(t, newID) - containedErr, ok := err.(xerrors.ContainedError) - require.True(t, ok) - err = containedErr.InnerError() - _, ok = err.(merrors.InvalidInputError) + err = xerrors.InnerError(err) + require.NotNil(t, err) + _, ok := err.(merrors.InvalidInputError) //nolint:errorlint require.True(t, ok) } @@ -842,10 +841,9 @@ func TestRuleSetAddRollupRuleDuplicateRule(t *testing.T) { newID, err := rs.AddRollupRule(view, helper.NewUpdateMetadata(nowNanos, testUser)) require.Error(t, err) require.Empty(t, newID) - containedErr, ok := err.(xerrors.ContainedError) - require.True(t, ok) - err = containedErr.InnerError() - _, ok = err.(merrors.InvalidInputError) + err = xerrors.InnerError(err) + require.NotNil(t, err) + _, ok := err.(merrors.InvalidInputError) //nolint:errorlint require.True(t, ok) } @@ -1207,10 +1205,9 @@ func TestApplyMappingRuleChangesAddFailure(t *testing.T) { helper := NewRuleSetUpdateHelper(10) err = rs.ApplyRuleSetChanges(changes, helper.NewUpdateMetadata(nowNanos, testUser)) require.Error(t, err) - containedErr, ok := err.(xerrors.ContainedError) - require.True(t, ok) - err = containedErr.InnerError() - _, ok = err.(merrors.InvalidInputError) + err = xerrors.InnerError(err) + require.NotNil(t, err) + _, ok := err.(merrors.InvalidInputError) //nolint:errorlint require.True(t, ok) } @@ -1240,10 +1237,9 @@ func TestApplyRollupRuleChangesAddFailure(t *testing.T) { helper := NewRuleSetUpdateHelper(10) err = rs.ApplyRuleSetChanges(changes, helper.NewUpdateMetadata(nowNanos, testUser)) require.Error(t, err) - containedErr, ok := err.(xerrors.ContainedError) - require.True(t, ok) - err = containedErr.InnerError() - _, ok = err.(merrors.InvalidInputError) + err = xerrors.InnerError(err) + require.NotNil(t, err) + _, ok := err.(merrors.InvalidInputError) //nolint:errorlint require.True(t, ok) } @@ -1270,10 +1266,9 @@ func TestApplyMappingRuleChangesDeleteFailure(t *testing.T) { helper := NewRuleSetUpdateHelper(10) err = rs.ApplyRuleSetChanges(changes, helper.NewUpdateMetadata(nowNanos, testUser)) require.Error(t, err) - containedErr, ok := err.(xerrors.ContainedError) - require.True(t, ok) - err = containedErr.InnerError() - _, ok = err.(merrors.InvalidInputError) + err = xerrors.InnerError(err) + require.NotNil(t, err) + _, ok := err.(merrors.InvalidInputError) //nolint:errorlint require.True(t, ok) } @@ -1300,10 +1295,9 @@ func TestApplyRollupRuleChangesDeleteFailure(t *testing.T) { helper := NewRuleSetUpdateHelper(10) err = rs.ApplyRuleSetChanges(changes, helper.NewUpdateMetadata(nowNanos, testUser)) require.Error(t, err) - containedErr, ok := err.(xerrors.ContainedError) - require.True(t, ok) - err = containedErr.InnerError() - _, ok = err.(merrors.InvalidInputError) + err = xerrors.InnerError(err) + require.NotNil(t, err) + _, ok := err.(merrors.InvalidInputError) //nolint:errorlint require.True(t, ok) }