Permalink
Browse files

Check whether there's a callback to handle the open error

  • Loading branch information...
1 parent dff7499 commit fadc4349f834dec652794bd6f1ae2e3074e77c98 Paul Gebheim committed Mar 16, 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 fadc434

Please sign in to comment.