Skip to content

Commit 5a5d032

Browse files
committed
Passing proper error object back from mapreduce method
1 parent dd4d9ba commit 5a5d032

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/mongodb/admin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ Admin.prototype.serverInfo = function(callback) {
1212
var databaseName = self.db.databaseName;
1313
self.db.databaseName = 'admin';
1414
this.db.executeDbCommand(command, function(err, doc) {
15-
self.db.databaseName = databaseName;
1615
if(err != null) return callback(err, null);
1716
return callback(null, doc.documents[0]);
1817
});
18+
// Ensure change before event loop executes
19+
self.db.databaseName = databaseName;
1920
}
2021

2122
Admin.prototype.profilingLevel = function(callback) {

lib/mongodb/collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ Collection.prototype.mapReduce = function(map, reduce, options, callback) {
512512
}
513513
});
514514
} else {
515-
err != null ? callback(err, null, null) : callback(new Error("map-reduce failed: " + result.documents[0].errmsg), null, null);
515+
err != null ? callback(err, null, null) : callback(result.documents[0], null, null);
516516
}
517517
});
518518
};

0 commit comments

Comments
 (0)