diff --git a/lib/client.js b/lib/client.js index dc7b776..58ae99c 100644 --- a/lib/client.js +++ b/lib/client.js @@ -89,7 +89,7 @@ Client.prototype.runCommand = function (command, arguments) { if( self.status == 'ready' || self.status == 'connecting') { self.client.VimService.VimPort[command]( cmdargs, function ( err, result, raw, soapHeader) { if( err ) { - _soapErrorHandler( self, emitter, command, cmdargs, err ); + return _soapErrorHandler( self, emitter, command, cmdargs, err ); } if( command == 'Logout') { self.status = 'disconnected'; @@ -105,7 +105,7 @@ Client.prototype.runCommand = function (command, arguments) { self.once('ready', function () { self.client.VimService.VimPort[command]( cmdargs, function ( err, result, raw, soapHeader) { if( err ) { - _soapErrorHandler( self, emitter, command, cmdargs, err ); + return _soapErrorHandler( self, emitter, command, cmdargs, err ); } if( command == 'Logout') { self.status = 'disconnected'; @@ -141,7 +141,7 @@ Client.prototype._connect = function () { soap.createClient(self._vcUrl, self.clientopts, function (err, client) { if( err ) { self.emit('error',err); - throw err; + return; } self.client = client; // save client for later use @@ -226,15 +226,15 @@ function _soapErrorHandler( self, emitter, command, arguments, err ) { }) .once('error', function (err) { emitter.emit('error',err.body); - throw err; + return emitter; }); } else { emitter.emit('error',err.body); - throw err; + return emitter; } } else { emitter.emit('error',err.body); - throw err; + return emitter; } };