Skip to content

Commit 17e76a4

Browse files
authored
Merge pull request #823 from ydb-platform/error-msg
fix error message
2 parents 61507d7 + b49a016 commit 17e76a4

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

internal/conn/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ func (c *conn) wrapError(err error) error {
464464
if err == nil {
465465
return nil
466466
}
467-
nodeErr := newNodeError(c.endpoint.NodeID(), c.endpoint.Address(), err)
467+
nodeErr := newConnError(c.endpoint.NodeID(), c.endpoint.Address(), err)
468468
return xerrors.WithStackTrace(nodeErr, xerrors.WithSkipDepth(1))
469469
}
470470

internal/conn/error.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ package conn
22

33
import "fmt"
44

5-
type nodeError struct {
6-
id uint32
5+
type connError struct {
6+
nodeID uint32
77
endpoint string
88
err error
99
}
1010

11-
func newNodeError(id uint32, endpoint string, err error) nodeError {
12-
return nodeError{
13-
id: id,
11+
func newConnError(id uint32, endpoint string, err error) connError {
12+
return connError{
13+
nodeID: id,
1414
endpoint: endpoint,
1515
err: err,
1616
}
1717
}
1818

19-
func (n nodeError) Error() string {
20-
return fmt.Sprintf("on node %v (%v): %v", n.id, n.endpoint, n.err)
19+
func (n connError) Error() string {
20+
return fmt.Sprintf("connError(node_id = %d, address = %q): %v", n.nodeID, n.endpoint, n.err)
2121
}
2222

23-
func (n nodeError) Unwrap() error {
23+
func (n connError) Unwrap() error {
2424
return n.err
2525
}

internal/conn/error_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99

1010
func TestNodeErrorError(t *testing.T) {
1111
testErr := errors.New("test")
12-
nodeErr := newNodeError(1, "localhost:1234", testErr)
12+
nodeErr := newConnError(1, "localhost:1234", testErr)
1313
message := nodeErr.Error()
1414

15-
require.Equal(t, "on node 1 (localhost:1234): test", message)
15+
require.Equal(t, "connError(node_id = 1, address = \"localhost:1234\"): test", message)
1616
}
1717

1818
func TestNodeErrorUnwrap(t *testing.T) {
1919
testErr := errors.New("test")
20-
nodeErr := newNodeError(1, "asd", testErr)
20+
nodeErr := newConnError(1, "asd", testErr)
2121

2222
unwrapped := errors.Unwrap(nodeErr)
2323
require.Equal(t, testErr, unwrapped)
@@ -26,7 +26,7 @@ func TestNodeErrorUnwrap(t *testing.T) {
2626
func TestNodeErrorIs(t *testing.T) {
2727
testErr := errors.New("test")
2828
testErr2 := errors.New("test2")
29-
nodeErr := newNodeError(1, "localhost:1234", testErr)
29+
nodeErr := newConnError(1, "localhost:1234", testErr)
3030

3131
require.True(t, errors.Is(nodeErr, testErr))
3232
require.False(t, errors.Is(nodeErr, testErr2))
@@ -50,7 +50,7 @@ func (t testErrorType2) Error() string {
5050

5151
func TestNodeErrorAs(t *testing.T) {
5252
testErr := testErrorType1{msg: "test"}
53-
nodeErr := newNodeError(1, "localhost:1234", testErr)
53+
nodeErr := newConnError(1, "localhost:1234", testErr)
5454

5555
target := testErrorType1{}
5656
require.True(t, errors.As(nodeErr, &target))

internal/conn/grpc_client_stream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (s *grpcClientStream) wrapError(err error) error {
132132
return nil
133133
}
134134

135-
nodeErr := newNodeError(s.c.endpoint.NodeID(), s.c.endpoint.Address(), err)
135+
nodeErr := newConnError(s.c.endpoint.NodeID(), s.c.endpoint.Address(), err)
136136
return xerrors.WithStackTrace(nodeErr, xerrors.WithSkipDepth(1))
137137
}
138138

0 commit comments

Comments
 (0)