Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x] Replace InnerError() method usages with xerrors.InnerError() #3068

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ctl/service/r2/store/kv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
42 changes: 18 additions & 24 deletions src/metrics/rules/ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down