Skip to content

Commit

Permalink
Removed Cause interface
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed Jun 25, 2024
1 parent 294cea1 commit 23e33ae
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 9 deletions.
File renamed without changes.
7 changes: 0 additions & 7 deletions fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ func (c *fields) Is(target error) bool {
return ok
}

// Cause returns the wrapped error which was the original
// cause of the issue. We only support this because some code
// depends on github.com/pkg/errors.Cause() returning the cause
// of the error.
// deprecated use error.Is() or error.As() instead
func (c *fields) Cause() error { return c.wrapped }

func (c *fields) Error() string {
return c.wrapped.Error()
}
Expand Down
3 changes: 1 addition & 2 deletions fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestFields(t *testing.T) {

assert.Equal(t, "value1", m["key1"])
assert.Equal(t, "message: query error", m["err"])
assert.Len(t, m, 3)
assert.Len(t, m, 2)
})

t.Run("Can use errors.Is() from std `errors` package", func(t *testing.T) {
Expand Down Expand Up @@ -60,7 +60,6 @@ func TestFields(t *testing.T) {
out := fmt.Sprintf("%+v", wrap)
assert.Contains(t, out, `message: query error (key1=value1)`)

var f errors.HasFields
if errors.As(wrap, &f) {
slog.Error("this error has log fields", f.Fields()...)
}
Expand Down

0 comments on commit 23e33ae

Please sign in to comment.