Permalink
Browse files

Merge pull request #41 from birthdayalarm/fix_connect_errors

Check whether there's a callback to handle the open error
  • Loading branch information...
2 parents dff7499 + fadc434 commit 851281c99c77f5533fb5bb26ffb6ec87dbeb9dd2 @guileen committed Mar 20, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/mongoskin/collection.js
@@ -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);
}

0 comments on commit 851281c

Please sign in to comment.