Browse Source

fix wrong use a nil value error `err` (#3365)

the `err` has been check abrove, so it is nil value,

check the errWrite != nil, should return `.Base(errWrite)`
alingse 7 months ago
parent
commit
21653e2ecf
1 changed files with 2 additions and 2 deletions
  1. 2 2
      transport/internet/websocket/dialer.go

+ 2 - 2
transport/internet/websocket/dialer.go

@@ -164,7 +164,7 @@ func (d dialerWithEarlyData) Dial(earlyData []byte) (*websocket.Conn, error) {
 	}
 	}
 	if n != int64(len(earlyData)) {
 	if n != int64(len(earlyData)) {
 		if errWrite := conn.WriteMessage(websocket.BinaryMessage, earlyData[n:]); errWrite != nil {
 		if errWrite := conn.WriteMessage(websocket.BinaryMessage, earlyData[n:]); errWrite != nil {
-			return nil, newError("failed to dial to (", d.uriBase, ") with early data as write of remainder early data failed: ").Base(err)
+			return nil, newError("failed to dial to (", d.uriBase, ") with early data as write of remainder early data failed: ").Base(errWrite)
 		}
 		}
 	}
 	}
 	return conn, nil
 	return conn, nil
@@ -209,7 +209,7 @@ func (d dialerWithEarlyDataRelayed) Dial(earlyData []byte) (io.ReadWriteCloser,
 	}
 	}
 	if n != int64(len(earlyData)) {
 	if n != int64(len(earlyData)) {
 		if _, errWrite := conn.Write(earlyData[n:]); errWrite != nil {
 		if _, errWrite := conn.Write(earlyData[n:]); errWrite != nil {
-			return nil, newError("failed to dial to (", d.uriBase, ") with early data as write of remainder early data failed: ").Base(err)
+			return nil, newError("failed to dial to (", d.uriBase, ") with early data as write of remainder early data failed: ").Base(errWrite)
 		}
 		}
 	}
 	}
 	return conn, nil
 	return conn, nil