From e417676254617e1e2e7bc68700bbade116295b62 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Mon, 28 Aug 2023 23:22:54 +0700 Subject: crypto/ssh: return error from NewClientConn with "%w" By returning error with %w, the caller can check and convert the error using errors.As, for example to knownhosts.KeyError. Change-Id: I0529e2e935cd8075f87aa6f6049cee3323f82c06 --- ssh/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssh/client.go b/ssh/client.go index bdc356c..fd8c497 100644 --- a/ssh/client.go +++ b/ssh/client.go @@ -82,7 +82,7 @@ func NewClientConn(c net.Conn, addr string, config *ClientConfig) (Conn, <-chan if err := conn.clientHandshake(addr, &fullConf); err != nil { c.Close() - return nil, nil, nil, fmt.Errorf("ssh: handshake failed: %v", err) + return nil, nil, nil, fmt.Errorf("ssh: handshake failed: %w", err) } conn.mux = newMux(conn.transport) return conn, conn.mux.incomingChannels, conn.mux.incomingRequests, nil -- cgit v1.3