Skip to content

bugfix: Is should return false when called without codes#59

Open
UmarFarooq-MP wants to merge 1 commit intomonzo:masterfrom
UmarFarooq-MP:fix-is-empty-code
Open

bugfix: Is should return false when called without codes#59
UmarFarooq-MP wants to merge 1 commit intomonzo:masterfrom
UmarFarooq-MP:fix-is-empty-code

Conversation

@UmarFarooq-MP
Copy link

Fixes #58

This change ensures that calling Is(err) without passing any code arguments returns false. Previously Is(err) would always return true, because PrefixMatches treats empty code as a match.

The fix adds an early guard if len(code) == 0 { return false } at the start of Is. New tests have been added to assert this behavior, including nested/unwrapped errors. All existing tests continue to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abnormal behaviour for Is in errors.go

1 participant