Skip to content

Conversation

@ytnsym
Copy link
Contributor

@ytnsym ytnsym commented Oct 14, 2024

This PR refactors error handling by replacing direct comparisons of errors (e.g., err == someError) with the use of errors.Is.

"github.com/ThreeDotsLabs/watermill/message"

"github.com/ThreeDotsLabs/watermill/message/router/middleware"
"github.com/pkg/errors"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see a need for this deprecated one

Remove it, so you can use errors directly without an alias

The call to errors.Wrap can be replaced by fmt.Errorf("%w ...")

errors.New can be used directly from stdlib

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like errors.Cause is being used in the current implementation, which makes it a bit more challenging to simply remove the alias.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I had seen before raising my point, errors.Cause is used only in the code, not in the test file I quoted.

But, I have missed something. And I was wrong

There is this indeed.

assert.Equal(t, errFailed, errors.Cause(multierr.WrappedErrors()[1]))

this could be rewritten to use maybe

assert.ErrorIs(t, multierr, errFailed)
@ccoVeille
Copy link

Also, maybe it's time to enable some golangci-lint linters

https://golangci-lint.run/usage/linters/

err113 is exacly the linter you need for catching what you are fixing.

errorlint is a good addition

Of course, this could be considered separately from this PR

@ytnsym ytnsym requested a review from ccoVeille October 15, 2024 14:07
Copy link

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to resolve directly my comment, or fix if you want to try.

But for me my comment was a detail, I'm fine with the code.

And thank you for opening the PR

@m110
Copy link
Member

m110 commented Aug 19, 2025

Thank you @ytnsym!

@m110 m110 merged commit cfb87ef into ThreeDotsLabs:master Aug 19, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants