File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package transport
1616
1717import (
1818 "context"
19+ "errors"
1920 "fmt"
2021 "net"
2122 "os"
@@ -26,6 +27,8 @@ import (
2627 "github.com/buraksezer/olric/internal/protocol"
2728)
2829
30+ var ErrConnPoolTimeout = errors .New ("timeout exceeded" )
31+
2932// Client is the client implementation for the internal TCP server.
3033// It maintains a connection pool and manages request-response cycle.
3134type Client struct {
@@ -129,7 +132,12 @@ func (c *Client) conn(addr string) (net.Conn, error) {
129132
130133 conn , err := p .Get (ctx )
131134 if err != nil {
132- return nil , err
135+ // Reformat the error here. DeadlineExceeded error is too
136+ // cryptic for users.
137+ if err == context .DeadlineExceeded {
138+ err = ErrConnPoolTimeout
139+ }
140+ return nil , fmt .Errorf ("failed to acquire a TCP connection from the pool for: %s %w" , addr , err )
133141 }
134142
135143 if c .config .HasTimeout () {
You can’t perform that action at this time.
0 commit comments