Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongoskin collection insert and/or save throw less helpful exception on invalid parameters #109

Open
fresheneesz opened this issue Jul 26, 2013 · 0 comments

Comments

@fresheneesz
Copy link
Contributor

When I do an insert or save with a write concern but without a callback, it rightly throws an exception. The problem is that it doesn't throw an exception until much later, much farther in the internals of mongoskin. This means that the exception I get back does not tell me where the line of code is that caused the problem.

This is the line where the exception is thrown:

else if(_hasWriteConcern(errorOptions) && callback == null) {
    throw new Error("Cannot use a writeConcern without a provided callback");
  } 

This is the exception I get:

Something borked:  - Error: Cannot use a writeConcern without a provided callback
    at insertAll (...\node_modules\mongoskin\node_modules\mongodb\lib\mongodb\collection.js:343:11)
    at Collection.insert (...\node_modules\mongoskin\node_modules\mongodb\lib\mongodb\collection.js:92:3)
    at EventEmitter.exports.bindSkin.obj.(anonymous function) (...\node_modules\mongoskin\lib\mongoskin\utils.js:68:23)
    at EventEmitter.g (events.js:175:14)
    at EventEmitter.emit (events.js:98:17)
    at SkinCollection.open (...\node_modules\mongoskin\lib\mongoskin\collection.js:129:24)
    at Db.collection (...\node_modules\mongoskin\node_modules\mongodb\lib\mongodb\db.js:484:44)
    at SkinCollection.open (...\node_modules\mongoskin\lib\mongoskin\collection.js:119:12)
    at SkinDb.open (...\node_modules\mongoskin\lib\mongoskin\db.js:79:19)
    at SkinCollection.open (...\node_modules\mongoskin\lib\mongoskin\collection.js:114:19)

Either mongoskin or mongodb must have some C++ junk that is blocking the full long-trace from generating. The correct solution would be to make it so whatever is blocking the long-trace does not do that. A more hacky solution would be to check the parameters immediately on call of insert or save so that the exception isn't thrown from the internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant