Skip to content

Commit

Permalink
Update some uses of errors.Cause() to errors.Is()
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed May 10, 2020
1 parent 082a8bd commit bb7ef2c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions cli-plugins/manager/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func (e *pluginError) Cause() error {
return e.cause
}

// Unwrap provides compatibility for Go 1.13 error chains.
func (e *pluginError) Unwrap() error {
return e.cause
}

// MarshalText marshalls the pluginError into a textual form.
func (e *pluginError) MarshalText() (text []byte, err error) {
return []byte(e.cause.Error()), nil
Expand Down
2 changes: 1 addition & 1 deletion cli-plugins/manager/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestPluginError(t *testing.T) {
inner := fmt.Errorf("testing")
err = wrapAsPluginError(inner, "wrapping")
assert.Error(t, err, "wrapping: testing")
assert.Equal(t, inner, errors.Cause(err))
assert.Assert(t, errors.Is(err, inner))

actual, err := yaml.Marshal(err)
assert.NilError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion cli/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestEmptyFile(t *testing.T) {
assert.NilError(t, err)

_, err = Load(tmpHome)
assert.Equal(t, errors.Cause(err), io.EOF)
assert.Assert(t, errors.Is(err, io.EOF))
assert.ErrorContains(t, err, ConfigFileName)
}

Expand Down

0 comments on commit bb7ef2c

Please sign in to comment.