simple code:
in initdb.js
var mongo = require('mongodb'),
MongoClient = mongo.MongoClient,
MongoServer = mongo.Server;
var mongoClient = new MongoClient(new MongoServer('host',port));
var db = mongoClient.db('db');
mongoClient.open(function (err, mongoclient) {
if (err) throw err;
});
If this code throws error, it would not be caught here main.js
app.use(function(err, req, res, next){
console.log('error here');
});
As a result I have errors and crashed app. I just want my app not crash. Any solutions?