Skip to content

Commit

Permalink
[x] Replace InnerError() method usages with xerrors.InnerError() (#3068)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpranckaitis authored Jan 11, 2021
1 parent 644bac3 commit dd84bb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
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

0 comments on commit dd84bb2

Please sign in to comment.