From 9fa5eb6d0abcb6abb7be0340018c2280e13eea18 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 17 May 2018 19:13:08 +0200 Subject: [PATCH] Debugging Improvements --- Run.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Run.js b/Run.js index a4779b6ea..c7c8c1e16 100644 --- a/Run.js +++ b/Run.js @@ -7,12 +7,14 @@ var fs = require('fs'); try { - global.PLATFORM_CONFIG = JSON.parse(fs.readFileSync('this.config.json', 'utf8')); + let configFile = fs.readFileSync('this.config.json', 'utf8'); + global.PLATFORM_CONFIG = JSON.parse(configFile); } catch (err) { - const logText = "[ERROR] 'readConfig' - ERROR : " + err.message; - console.log(logText); + + console.log("[ERROR] Run -> readConfig -> Error Reading the AACloud Config File."); + console.log("[ERROR] Run -> readConfig -> err.message = " + err.message); return; } @@ -29,17 +31,28 @@ const MODULE_NAME = "Run"; const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); process.on('uncaughtException', function (err) { - logger.write('uncaughtException - ' + err.message); + console.log('[INFO] Run -> uncaughtException -> err.message = ' + err.message); + return; }); process.on('unhandledRejection', (reason, p) => { - logger.write("Unhandled Rejection at: Promise " + JSON.stringify(p) + " reason: " + reason); + console.log('[INFO] Run -> unhandledRejection -> reason = ' + reason); + console.log('[INFO] Run -> unhandledRejection -> p = ' + JSON.stringify(p)); + return; }); process.on('exit', function (code) { - logger.write('About to exit with code:' + code); + try { + console.log('[INFO] Run -> process.on.exit -> About to exit -> code = ' + code); + return; + } + catch (err) { + console.log("[ERROR] Run -> process.on.exit -> Error Logging Error Code."); + console.log("[ERROR] Run -> process.on.exit -> err.message = " + err.message); + return; + } }); /* Global constants definitions. */ @@ -150,7 +163,8 @@ for (let p = 0; p < global.PLATFORM_CONFIG.executionList.length; p++) { try { - botConfig = JSON.parse(fs.readFileSync(listItem.botPath + '/this.bot.config.json', 'utf8')); + let botConfigFile = fs.readFileSync(listItem.botPath + '/this.bot.config.json', 'utf8'); + botConfig = JSON.parse(botConfigFile); } catch (err) { console.log("[ERROR] 'readConfig' - ERROR : " + err.message);