@@ -175,7 +175,7 @@ TarantoolConnection.prototype._processResponse = function(buffer){
175175 if ( success )
176176 dfd . resolve ( this . _processResponseBody ( task [ 0 ] , obj [ 1 ] [ tarantoolConstants . KeysCode . data ] ) ) ;
177177 else
178- dfd . reject ( obj [ 1 ] [ tarantoolConstants . KeysCode . error ] ) ;
178+ dfd . reject ( new Error ( obj [ 1 ] [ tarantoolConstants . KeysCode . error ] ) ) ;
179179 if ( this . awaitingDestroy && this . commandsQueue . length == 1 )
180180 {
181181 this . commandsQueue [ 0 ] [ 2 ] . resolve ( true ) ;
@@ -192,7 +192,7 @@ TarantoolConnection.prototype.onConnect = function(){
192192} ;
193193
194194TarantoolConnection . prototype . onError = function ( error ) {
195- this . _interupt ( ) ;
195+ this . _interupt ( error ) ;
196196 this . _stubMethods ( ) ;
197197 this . socket . destroy ( ) ;
198198 this . commandsQueue = [ ] ;
@@ -222,7 +222,7 @@ TarantoolConnection.prototype.connect = function(){
222222 }
223223 else
224224 {
225- reject ( this . awaitingDestroy ? 'already destroyed' : 'already connected' ) ;
225+ reject ( new Error ( this . awaitingDestroy ? 'already destroyed' : 'already connected' ) ) ;
226226 if ( this . options . log )
227227 {
228228 console . log ( 'connection already destroyed' ) ;
@@ -270,24 +270,29 @@ TarantoolConnection.prototype.select = function(spaceId, indexId, limit, offset,
270270
271271TarantoolConnection . prototype . delete = function ( spaceId , indexId , key ) {
272272 return new Promise ( function ( resolve , reject ) {
273- var reqId = requestId . getId ( ) ;
274- var header = this . _header ( tarantoolConstants . RequestCode . rqDelete , reqId ) ;
275- var buffered = {
276- spaceId : msgpack . encode ( spaceId ) ,
277- indexId : msgpack . encode ( indexId ) ,
278- key : msgpack . encode ( key )
279- } ;
280- var body = Buffer . concat ( [ new Buffer ( [ 0x86 , tarantoolConstants . KeysCode . space_id ] ) , buffered . spaceId ,
281- new Buffer ( [ tarantoolConstants . KeysCode . index_id ] ) , buffered . indexId ,
282- new Buffer ( [ tarantoolConstants . KeysCode . key ] ) , buffered . key ] ) ;
283- this . _request ( header , body ) ;
284- this . commandsQueue . push ( [ tarantoolConstants . RequestCode . rqSelect , reqId , { resolve : resolve , reject : reject } ] ) ;
273+ if ( Array . isArray ( key ) )
274+ {
275+ var reqId = requestId . getId ( ) ;
276+ var header = this . _header ( tarantoolConstants . RequestCode . rqDelete , reqId ) ;
277+ var buffered = {
278+ spaceId : msgpack . encode ( spaceId ) ,
279+ indexId : msgpack . encode ( indexId ) ,
280+ key : msgpack . encode ( key )
281+ } ;
282+ var body = Buffer . concat ( [ new Buffer ( [ 0x86 , tarantoolConstants . KeysCode . space_id ] ) , buffered . spaceId ,
283+ new Buffer ( [ tarantoolConstants . KeysCode . index_id ] ) , buffered . indexId ,
284+ new Buffer ( [ tarantoolConstants . KeysCode . key ] ) , buffered . key ] ) ;
285+ this . _request ( header , body ) ;
286+ this . commandsQueue . push ( [ tarantoolConstants . RequestCode . rqSelect , reqId , { resolve : resolve , reject : reject } ] ) ;
287+ }
288+ else
289+ reject ( new Error ( 'need array' ) ) ;
285290 } . bind ( this ) ) ;
286291} ;
287292
288293TarantoolConnection . prototype . update = function ( spaceId , indexId , key , ops ) {
289294 return new Promise ( function ( resolve , reject ) {
290- if ( Array . isArray ( ops ) ) {
295+ if ( Array . isArray ( ops ) && Array . isArray ( key ) ) {
291296 var reqId = requestId . getId ( ) ;
292297 var header = this . _header ( tarantoolConstants . RequestCode . rqUpdate , reqId ) ;
293298 var buffered = {
@@ -325,7 +330,7 @@ TarantoolConnection.prototype.eval = function(expression){
325330} ;
326331
327332TarantoolConnection . prototype . call = function ( functionName ) {
328- var tuple = Array . prototype . slice . call ( arguments , 1 ) ;
333+ var tuple = arguments . length > 1 ? Array . prototype . slice . call ( arguments , 1 ) : [ ] ;
329334 return new Promise ( function ( resolve , reject ) {
330335 var reqId = requestId . getId ( ) ;
331336 var header = this . _header ( tarantoolConstants . RequestCode . rqCall , reqId ) ;
@@ -412,7 +417,7 @@ TarantoolConnection.prototype.destroy = function(interupt){
412417 return new Promise ( function ( resolve , reject ) {
413418 if ( interupt )
414419 {
415- this . _interupt ( 'force destroy socket' ) ;
420+ this . _interupt ( new Error ( 'force destroy socket' ) ) ;
416421 this . socket . destroy ( ) ;
417422 resolve ( true ) ;
418423 }
@@ -437,7 +442,7 @@ TarantoolConnection.prototype.destroy = function(interupt){
437442
438443TarantoolConnection . prototype . _notAvailableMethod = function ( ) {
439444 return new Promise ( function ( resolve , reject ) {
440- reject ( 'connection will be destroyed or already destroyed, create another one' ) ;
445+ reject ( new Error ( 'connection will be destroyed or already destroyed, create another one' ) ) ;
441446 } ) ;
442447} ;
443448
0 commit comments