-
Notifications
You must be signed in to change notification settings - Fork 182
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
Catch connection errors #24
Comments
+1, trying to get some kind of feedback that the connection hasn't been established. |
Yep basically we need to re-emit as |
I also wonder whether we have |
haha, i was actually getting Here's what i had: monk = require('monk')(url);
monk.on('open', function() {
// prob shouldn't be firing when mongod not running...
}); |
+1 |
Maybe the bug is on this.driver.open(this.onOpen.bind(this)); What if we just pass a callback and emit events?, something like: var _this = this;
this.driver.open(function (error) {
if (error) {
_this.emit('error', error);
} else {
_this.emit('open')
}
});
...
if (fn) {
this.once('open', fn);
this.once('error', fn);
} Then we can pass a callback to check for errors, something like: var db = monk(uri, function(err) {
if (err) console.error(err);
}); or var db = monk(uri, opts, function(err) {
if (err) console.error(err);
}); or var db = monk(uri);
db.on('error', function (err) { console.error(err); })
db.on('open', function () { console.log('open'); }); Mongoskin will return an error if the connection fails:
|
Right now
error
s from mongoskin/native emitters are not being catched.They should be re-emitted so that they can be captured by
manager.on('error')
The text was updated successfully, but these errors were encountered: