Mongo errors management
Currently (and related to #25 (closed)) we have no all the errors of mongo under control. Actually, re-connection does not seem to be working.
I think, the problem is more relate to node.js basis about excepctions management. Some exceptoins are been captured by express framework because of this code:
app.use(function (err, req, res, next) {
// console.error(err.stack);
if (err instanceof SyntaxError) {
logger.error('app.use(): ' + err.message);
errorsManagement.sendError(errorsManagement.INCORRECT_MODEL_ERROR, res);
} else {
logger.error('app.use(): ' + err.message);
errorsManagement.sendError(errorsManagement.UNKNOWN_ERROR, res);
}
});
Instead it should be managed by mongoclient.on('exceptions'...) code.
A good way of start working on this, it just include a wrong code after mongo connection like:
dbClientAEON.getClient()
getClient is not an existing function, so whatever it will cause a fail.
Also you can test reconnection is not working just shutting down the mongo server, if you do a request, express framewrok will capture the error saying somethig like:
no open connections