Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match error handlers using "errors" package #7

Open
bkmeneguello opened this issue Oct 24, 2024 · 2 comments
Open

Match error handlers using "errors" package #7

bkmeneguello opened this issue Oct 24, 2024 · 2 comments

Comments

@bkmeneguello
Copy link

Currently the error handler converts the registered errors to a string and the matcher just matches the string representation of the provided error. If the error is wrapped inside another error this check fails.

My suggestion is registering the error handlers either as an error reference or an interface {Error() string} type, and use the methods errors.Is and errors.As to match them.

@survivorbat
Copy link
Contributor

Hey @bkmeneguello, thanks for the suggestion! This sounds like a great improvement. I do think it'd require a change in the interface of the ErrorRegistry, to be able to register an instantiated object in the registry map. So a v3 would likely be necessary. Something like RegisterErrorHandler[E error](error, func (context.Context, error) (int, any) perhaps.

I'll play around with it and see what a v3 could look like :)

@survivorbat
Copy link
Contributor

Could you check out #8? 😎

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

No branches or pull requests

2 participants