Unable to catch errors
The error event is not working, considering the following code:
var Vsphere = require('vsphere');
var vc = new Vsphere.Client('myhost', 'myuser', 'mypass', false);
vc.once('ready', function() {
console.log('vSphere ready');
});
vc.once('error', function(err) {
console.log('vSphere error: ' + err.message);
});
If I change the host to something where the API is not present:
events.js:160
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:443
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
If I change the user or password to something invalid:
events.js:165
throw err;
^
Error: Uncaught, unspecified "error" event. (<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault><faultcode>ServerFaultCode</faultcode><faultstring>Cannot complete login due to an incorrect user name or password.</faultstring><detail><InvalidLoginFault xmlns="urn:vim25" xsi:type="InvalidLogin"></InvalidLoginFault></detail></soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>)
at Client.emit (events.js:163:17)
at EventEmitter.<anonymous> (/home/vdix98r/Workspace/telcel_kue/node_modules/node-vsphere-soap/lib/client.js:178:14)
at EventEmitter.g (events.js:291:16)
at emitOne (events.js:96:13)
at EventEmitter.emit (events.js:188:7)
at _soapErrorHandler (/home/vdix98r/Workspace/telcel_kue/node_modules/node-vsphere-soap/lib/client.js:236:13)
at /home/vdix98r/Workspace/telcel_kue/node_modules/node-vsphere-soap/lib/client.js:92:9
at /home/vdix98r/Workspace/telcel_kue/node_modules/soap/lib/client.js:130:7
at /home/vdix98r/Workspace/telcel_kue/node_modules/soap/lib/client.js:230:16
at Request._callback (/home/vdix98r/Workspace/telcel_kue/node_modules/soap/lib/http.js:60:7)
Versions:
├─┬ [email protected]
│ └─┬ [email protected]
@Syavne you can try my fork https://github.com/korzhev/node-vsphere, with some fixed issue including this one.
I am also facing the same issue, when I try to provide any incorrect credentials, then it throws a bunch of error messages on console like this:
error contents :
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
soapenv:Body
soapenv:Fault
I want to contain this and in case of errors i want to print just error message on the console. Any ideas how can this be achieved?