-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
server,cli: fix improperly wrapped errors #72352
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice. I already love your linter.
Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)
pkg/cli/clisqlclient/conn_test.go, line 68 at r1 (raw file):
testutils.SucceedsSoon(t, func() error { if sqlRows, err := conn.Query(`SELECT 1`, nil); !errors.Is(err, driver.ErrBadConn) { return errors.AssertionFailedf("expected ErrBadConn, got %v", err)
NewAssertionErrorWithWrappedErrf
? same below
pkg/server/drain_test.go, line 90 at r1 (raw file):
return nil } return errors.AssertionFailedf("server not yet refusing RPC, got %v", err)
assertion with wrap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @knz)
pkg/cli/clisqlclient/conn_test.go, line 68 at r1 (raw file):
Previously, knz (kena) wrote…
NewAssertionErrorWithWrappedErrf
? same below
Done.
pkg/server/drain_test.go, line 90 at r1 (raw file):
Previously, knz (kena) wrote…
assertion with wrap
Done.
330685b
to
b12219b
Compare
tftr! bors r=knz |
Build failed: |
bors r=knz |
72352: server,cli: fix improperly wrapped errors r=knz a=rafiss refs #42510 I'm working on a linter that detects errors that are not wrapped correctly, and it discovered these. Release note: None Co-authored-by: Rafi Shamim <[email protected]>
Build failed: |
bors r=knz |
Build failed (retrying...): |
bors r- |
Canceled. |
made a mistake in review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @knz and @rafiss)
pkg/server/drain_test.go, line 90 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
Done.
please revert this one. we want an error to be returned by this function when Dial returns a nil error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @knz)
pkg/server/drain_test.go, line 90 at r1 (raw file):
Previously, knz (kena) wrote…
please revert this one. we want an error to be returned by this function when Dial returns a nil error.
not sure what the best way to do this is while still keeping the forthcoming linter happy. i could do
errS := "<nil>"
if err != nil {
errS = err.Error()
}
return errors.Newf("server not yet refusing RPC, got %s", errS)
which seems gross.
should i keep it as is and instead allow a //nolint
directive similar to
if strings.Contains(c.Text, "nolint:fmtsafe") { |
yes a nolint comment in this case seems appropriate. if err != nil {
if grpc.XXX(err) {
return nil
}
return errors.NewAssertion...(err, "...")
}
// nil err
return errors.AssertionFailed("dial did not fail") |
thanks, i'll add |
I'm working on a linter that detects errors that are not wrapped correctly, and it discovered these. Release note: None
b12219b
to
2407d3f
Compare
tftr! bors r=knz |
Build succeeded: |
71877: lint: add new errwrap linter r=ajwerner,knz a=rafiss fixes #42510 This linter checks if we don't correctly wrap errors. The `/* nolint:errwrap */` comment can be used to disable the linter inline. See individual commits for mistakes this linter caught. It had already caught a few in #72353, #72352, #72351, #72350, and #72349. Release note: None Co-authored-by: Rafi Shamim <[email protected]>
refs #42510
I'm working on a linter that detects errors that are not wrapped
correctly, and it discovered these.
Release note: None