Commit c78059a3 authored by Rob Swindell's avatar Rob Swindell

Store the socket error description before closing the socket.

Also, don't include "error" in the Error message.
Also, socket error strings can be quite long on Windows (e.g. >128 chars)
so place at the end of the Error message.
parent 8336ea34
Pipeline #244 passed with stage
in 17 minutes and 35 seconds
......@@ -102,9 +102,10 @@ function JSONClient(serverAddr,serverPort) {
this.socket=new Socket();
if(!this.socket.connect(this.serverAddr,this.serverPort,this.settings.CONNECTION_TIMEOUT)) {
var connect_error = this.socket.error
var connect_error = this.socket.error;
var connect_error_str = this.socket.error_str;
this.socket.close();
throw new Error("error " + connect_error + " (" + socket_errno_str + ") connecting to TCP port " + this.serverPort + " on server " + this.serverAddr);
throw new Error(connect_error + " connecting to TCP port " + this.serverPort + " on server " + this.serverAddr + ": " + connect_error_str);
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment