Skip to content

Commit

Permalink
Merge pull request kissjs#41 from birthdayalarm/fix_connect_errors
Browse files Browse the repository at this point in the history
Check whether there's a callback to handle the open error
  • Loading branch information
guileen committed Mar 20, 2012
2 parents dff7499 + fadc434 commit 851281c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/mongoskin/collection.js
Expand Up @@ -69,7 +69,12 @@ var bindSkin = function(name, method) {
var args = arguments.length > 0 ? __slice.call(arguments, 0) : [];
this.open(function(err, collection) {
if (err) {
args[args.length - 1](err);
var cb = args.pop();
if(cb) {
cb(err)
} else {
console.error("Error occured with no callback to handle it while calling SkinCollection." + name, err);
}
} else {
method.apply(collection, args);
}
Expand Down

0 comments on commit 851281c

Please sign in to comment.