Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 085915a

Browse files
committed
Update some uses of errors.Cause() to errors.Is()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit bb7ef2cb3afba7787388cc9d65017b8135393ec8) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 9a57ea886934a79c17663ae22640f2288e3a85a1 Component: cli
1 parent 6a461fe commit 085915a

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

components/cli/cli-plugins/manager/error.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ func (e *pluginError) Cause() error {
2525
return e.cause
2626
}
2727

28+
// Unwrap provides compatibility for Go 1.13 error chains.
29+
func (e *pluginError) Unwrap() error {
30+
return e.cause
31+
}
32+
2833
// MarshalText marshalls the pluginError into a textual form.
2934
func (e *pluginError) MarshalText() (text []byte, err error) {
3035
return []byte(e.cause.Error()), nil

components/cli/cli-plugins/manager/error_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestPluginError(t *testing.T) {
1616
inner := fmt.Errorf("testing")
1717
err = wrapAsPluginError(inner, "wrapping")
1818
assert.Error(t, err, "wrapping: testing")
19-
assert.Equal(t, inner, errors.Cause(err))
19+
assert.Assert(t, errors.Is(err, inner))
2020

2121
actual, err := yaml.Marshal(err)
2222
assert.NilError(t, err)

components/cli/cli/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestEmptyFile(t *testing.T) {
8080
assert.NilError(t, err)
8181

8282
_, err = Load(tmpHome)
83-
assert.Equal(t, errors.Cause(err), io.EOF)
83+
assert.Assert(t, errors.Is(err, io.EOF))
8484
assert.ErrorContains(t, err, ConfigFileName)
8585
}
8686

0 commit comments

Comments
 (0)