diff --git a/libgm/events/ready.go b/libgm/events/ready.go index 787721a..e9122af 100644 --- a/libgm/events/ready.go +++ b/libgm/events/ready.go @@ -45,9 +45,9 @@ func (re RequestError) Error() string { } func (re RequestError) Is(other error) bool { - otherRe, ok := other.(RequestError) - if !ok { - return errors.Is(*re.HTTP, other) + var otherRe RequestError + if !errors.As(other, &otherRe) { + return re.HTTP != nil && errors.Is(*re.HTTP, other) } return otherRe.Data.GetType() == re.Data.GetType() && otherRe.Data.GetMessage() == re.Data.GetMessage() diff --git a/libgm/events/ready_test.go b/libgm/events/ready_test.go index 24e6b2c..6b14957 100644 --- a/libgm/events/ready_test.go +++ b/libgm/events/ready_test.go @@ -2,6 +2,7 @@ package events_test import ( "encoding/base64" + "fmt" "testing" "github.com/stretchr/testify/assert" @@ -18,6 +19,7 @@ func TestRequestError_Is(t *testing.T) { err := pblite.Unmarshal(dat, &errResp) require.NoError(t, err) assert.ErrorIs(t, events.RequestError{Data: &errResp}, events.ErrRequestedEntityNotFound) + assert.ErrorIs(t, events.RequestError{Data: &errResp}, fmt.Errorf("meow: %w", events.ErrRequestedEntityNotFound)) assert.NotErrorIs(t, events.RequestError{Data: &errResp}, events.RequestError{ Data: &gmproto.ErrorResponse{ Type: 5,