Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
updating error handler to exit the node app if we cant establish acce…
Browse files Browse the repository at this point in the history
…ss to mongodb for some reason
  • Loading branch information
lirantal committed Dec 3, 2014
1 parent 9c25722 commit 4d9d5ec
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ var db = mongoose.connect(config.db.uri, config.db.options, function(err) {
console.log(chalk.red(err));
}
});
mongoose.connection.on('error', console.error.bind(console, chalk.red('MongoDB connection error:')));
mongoose.connection.on('error', function(err) {
console.error(chalk.red('MongoDB connection error: ' + err));
process.exit(-1);
}
);

// Init the express application
var app = require('./config/express')(db);
Expand Down

0 comments on commit 4d9d5ec

Please sign in to comment.