From c851d1d808bcde7ab69428b5e42b0068fff017c6 Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Sun, 29 Jul 2018 19:35:58 -0400 Subject: [PATCH] Add uncaught exception handler --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 3c8df14..8ef1e20 100755 --- a/server.js +++ b/server.js @@ -11,12 +11,17 @@ const helmet = require('helmet'); const app = express(); const config = require('config'); +process.on('uncaughtException', function (err) { + console.log('FATAL UNCAUGHT EXCEPTION:'); + console.log(err.stack); +}); + // MongoDB const dbHost = config.get('Database.host'); let db; mongoose.connect(dbHost, {useNewUrlParser: true}) .then(() => { - console.log('Connected to database ' + dbHost); + console.log('Connected to database ' + dbHost + '\n'); db = mongoose.connection; });