Skip to content

IsAny() multi error support - #140

Merged
dhartunian merged 1 commit into
cockroachdb:masterfrom
nikitacrit:IsAny-multi-error-support
May 24, 2024
Merged

IsAny() multi error support#140
dhartunian merged 1 commit into
cockroachdb:masterfrom
nikitacrit:IsAny-multi-error-support

Conversation

@nikitacrit

@nikitacritnikitacrit commented May 6, 2024

Copy link
Copy Markdown
Contributor

Hello! At the moment the following code will produce the result "no". I suggest a fix based on the code found in the original method Is().

funcmain() {
err:=errors.Join(io.EOF, errors.New("gopher"))
iferrors.IsAny(err, io.EOF, net.ErrClosed) {
fmt.Print("yes")
} else {
fmt.Print("no")
}
}

This change is Reviewable

@cockroach-teamcity

cockroach-teamcity commented May 6, 2024

Copy link
Copy Markdown
Member

CLA assistant check
All committers have signed the CLA.

@nikitacrit

Copy link
Copy Markdown
ContributorAuthor

@dhartunian Hi David. I see your latest activity in this repository and would like to ask if contributions are welcome and if someone can review the changes?

@dhartunian
dhartunian self-requested a review May 7, 2024 18:02
@dhartunian

Copy link
Copy Markdown
Contributor

@nikitacrit thanks for the ping, I'll take a look when I get a chance, probably over the next few days.

@dhartuniandhartunian self-assigned this May 7, 2024
Comment threadmarkers/markers.go
"github.com/gogo/protobuf/proto"

"github.com/cockroachdb/errors/errbase"
"github.com/cockroachdb/errors/errorspb"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: revert the import reordering.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done! And sorry I was forced to force push to keep the commit history clean.

err4 := pkgErr.Wrap(err2, "universe")
err5 := errors.Join(err1, errors.New("gopher"))
err6 := errors.Join(errors.New("gopher"), err2)
err7 := errors.Join(err1, err2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a test case that wraps at the top level? That will ensure that the implementation is necessary within the UnwrapOnce loop instead of outside.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done!

@nikitacrit
nikitacritforce-pushed the IsAny-multi-error-support branch from 51ebea5 to b0e6c50CompareMay 15, 2024 20:27

@dhartuniandhartunian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:lgtm: thanks for the changes.

Reviewed 1 of 2 files at r2.
Reviewable status: 1 of 2 files reviewed, all discussions resolved


markers/markers.go line 26 at r1 (raw file):

Previously, nikitacrit (Nikita Sidorov) wrote…

Done! And sorry I was forced to force push to keep the commit history clean.

👍 I prefer squashed commits

@dhartunian
dhartunian merged commit f0b6870 into cockroachdb:masterMay 24, 2024
Sign up for freeto 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.

3 participants

@nikitacrit@cockroach-teamcity@dhartunian