I think this that wasn't working for you then:
db.on('error', function(err) {
console.log('Catch ', err);
});
because it was an issue posted on Github that finally got solved, have a look here... so you can now catch it with any problems (I am using it that way inside some of my coding and it is working!).
You can go further, and pass an err
parameter inside your callbacks, for example like this:
db.collection.insert( { foo: "foo_value" }, function(err) {
if (err) {
console.log(" Woops! The error took place here... ");
} else {
console.log(" Everything went neat! ");
}
});
...to know where that error took place. This is working really nice for me.