-
Notifications
You must be signed in to change notification settings - Fork 976
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
surface original network errors and create error stacks #425
surface original network errors and create error stacks #425
Conversation
@@ -80,7 +80,7 @@ func (c *Conn) ReadPacketTo(w io.Writer) error { | |||
header := []byte{0, 0, 0, 0} | |||
|
|||
if _, err := io.ReadFull(c.Conn, header); err != nil { | |||
return ErrBadConn | |||
return errors.Wrapf(ErrBadConn, "io.ReadFull(header) failed. err %v", err) |
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.
preserving dummy ErrBadConn
here, because code in canal/canal.go, failover/server.go and driver/driver.go is checking for it by applying errors.Cause
@@ -177,17 +177,19 @@ func (c *Conn) WritePublicKeyAuthPacket(password string, cipher []byte) error { | |||
// request public key | |||
data := make([]byte, 4+1) | |||
data[4] = 2 // cachingSha2PasswordRequestPublicKey | |||
c.WritePacket(data) | |||
if err := c.WritePacket(data); err != nil { |
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.
I took a liberty to add error checking here
PTAL @GregoryIan can this break the compatibility? if we check ErrBadConn error outside directly? |
Cool Job!Please resolve conflicts @gleonid |
@siddontang If choosing, I expect the client to use |
Is it necessary to wrap all the errors? or just handling some specific errors is fine? |
Clearly it is not necessary to neither wrap, nor check (line 180) all errors, as it functions fine without any of that. |
1690d5f
to
090ed8f
Compare
done |
In terms of priorities this is a very minor change.
in some cases, like packet/conn.go:83, root cause error is being lost
surfacing original errors is useful for troubleshoot production issues