File tree Expand file tree Collapse file tree 3 files changed +4
-2
lines changed Expand file tree Collapse file tree 3 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -402,7 +402,7 @@ var executeCommands = function(self, callback) {
402
402
// If we are ordered and have errors and they are
403
403
// not all replication errors terminate the operation
404
404
if ( self . s . bulkResult . writeErrors . length > 0 ) {
405
- return callback ( self . s . bulkResult . writeErrors [ 0 ] , new BulkWriteResult ( self . s . bulkResult ) ) ;
405
+ return callback ( toError ( self . s . bulkResult . writeErrors [ 0 ] ) , new BulkWriteResult ( self . s . bulkResult ) ) ;
406
406
}
407
407
408
408
// Execute the next command in line
Original file line number Diff line number Diff line change @@ -431,7 +431,7 @@ var executeBatches = function(self, callback) {
431
431
432
432
// Execute
433
433
if ( numberOfCommandsToExecute == 0 ) {
434
- var error = self . s . bulkResult . writeErrors . length > 0 ? self . s . bulkResult . writeErrors [ 0 ] : null ;
434
+ var error = self . s . bulkResult . writeErrors . length > 0 ? toError ( self . s . bulkResult . writeErrors [ 0 ] ) : null ;
435
435
callback ( error , new BulkWriteResult ( self . s . bulkResult ) ) ;
436
436
}
437
437
} ) ;
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ exports['Should correctly handle ordered multiple batch api write command error'
82
82
// Execute the operations
83
83
batch . execute ( function ( err , result ) {
84
84
// Basic properties check
85
+ test . equal ( err instanceof Error , true ) ;
85
86
test . equal ( 1 , result . nInserted ) ;
86
87
test . equal ( true , result . hasWriteErrors ( ) ) ;
87
88
test . ok ( 1 , result . getWriteErrorCount ( ) ) ;
@@ -484,6 +485,7 @@ exports['Should correctly handle single unordered batch API'] = {
484
485
// Execute the operations
485
486
batch . execute ( function ( err , result ) {
486
487
// Basic properties check
488
+ test . equal ( err instanceof Error , true ) ;
487
489
test . equal ( 2 , result . nInserted ) ;
488
490
test . equal ( 0 , result . nUpserted ) ;
489
491
test . equal ( 0 , result . nMatched ) ;
You can’t perform that action at this time.
0 commit comments