From 88db4a082cb6cc52e0fdd3af9c9c4c81f4e3c2b2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 29 Apr 2018 11:00:57 +0200 Subject: [PATCH] First Part Handling ERR in responses --- .vs/AAWeb/v15/.suo | Bin 59904 -> 66048 bytes Dashboard.js | 28 ++++++++++- Files/FileCloud.js | 77 ++++++++++++++++++++++------ Files/FileSequence.js | 95 +++++++++++++++++++++++++++++++++-- ProductStorage.js | 114 ++++++++++++++++++++++-------------------- Spaces/ChartSpace.js | 2 +- TimelineChart.js | 38 ++++++++++++-- 7 files changed, 275 insertions(+), 79 deletions(-) diff --git a/.vs/AAWeb/v15/.suo b/.vs/AAWeb/v15/.suo index 5b6ce0a02a201e8eb5166fb8d88bc2d050ecf3b4..9a858dd1e574f2442dfff25b5af77e03e88876fa 100644 GIT binary patch delta 3616 zcmeHJZ%kBI7Jv8649qaYI0B9o5C+O3Dw08|OYKsjJjG&)LyIm|{DYN*QWSxi6j94q zO_R242j;i6x>jAM-NqGMhk1P3x^|RWXkw_zHv6I5cKxu)x+YECq;~Bll|AS29>vve z+BDhp!`_+S+XUP+&mk<;<$2Vv z#tw6)sK$%toZe+5I|-%wI_q#tC%J$yi|{ZZjo>9LC-C~u^uA2**;j5Ax?Dv4BZMk~ zLRd-2An=|{>VHnCktEEwRHmc?(WXsLbX zFgg+r%w*tERNemoZY35zb|39aATR|B35A3?1UDg<@HHEw=Am&mfyYVI8&t9EAepIJ z#Z>jKppl(WLP#YnA>9T zKd^DOXdkFcMUidqoM&iX8({}wCxOp;5`VDGzpsa+y#&^JPVakp2fnrqS_f(LHUZJ3 z1`8|Q9%$O4w%M&hTtvXpE8f9P`aO?8@>(;~g35{_e33lzZJM)YYPt+fzBf~vvx5n1 zNI2$3Ps+cjXoRR#Ffo{}Zd&$6 zX1G+bT4^y$->Ldb`$X(_>$dT>lyN$Q?nZiBY@;6-U>9zCGde*Cxfk%beH*NUYzSypyaL%G-&Ob>K z^u^f@kFd~hU3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l_h7l^FW-G|p3Ymp1@^%_iZXxbBQ)F#Kwp0rZNn2y8rEQcav*N?FTp^k zMjI_`6t@d!PFjv8^_xIyLuYY zOp+uH8CeE}vJ|J^)3A6HKT1K(MKAOYPe(XC)}-M?C>;`RJu!IY(I+}VSVQm7Ey6kh zVaN6Ve*wyk-=r`Wi92<{uT*gI?)D|@g|)Ou@k*5=A+9^*rOIX|GCSkXCNMMe*& Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> pBot = " + pBot.codeName); } + blobService = AzureStorage.Blob.createBlobServiceWithSas(pBot.storage.fileUri, pBot.storage.sas); } function getFile(pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, callBackFunction) { + if (FULL_LOG === true) { logger.write("[INFO] getFile -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] getFile -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pSet.filePath + "-" + pSet.fileName); } + let fileName = pSet.fileName; let filePath = pSet.filePath; if (fileName === undefined) { - console.log("Inconsistant data. Check the following: "); - console.log(JSON.stringify(pDevTeam)); - console.log(JSON.stringify(pBot)); - console.log(JSON.stringify(pSet)); - console.log(JSON.stringify(pExchange)); - console.log(JSON.stringify(pMarket)); - console.log(JSON.stringify(pPeriodName)); + logger.write("[ERROR] getFile -> Inconsistant data. Check the following: "); + logger.write("[ERROR] getFile -> pDevTeam = " + JSON.stringify(pDevTeam)); + logger.write("[ERROR] getFile -> pBot = " + JSON.stringify(pBot)); + logger.write("[ERROR] getFile -> pSet = " + JSON.stringify(pSet)); + logger.write("[ERROR] getFile -> pExchange = " + JSON.stringify(pExchange)); + logger.write("[ERROR] getFile -> pMarket = " + JSON.stringify(pMarket)); + logger.write("[ERROR] getFile -> pPeriodName = " + JSON.stringify(pPeriodName)); throw ("Inconsistant data received."); } @@ -74,21 +83,46 @@ function newFileCloud() { fileName = fileName.replace("@Sequence", pSequence); } - blobService.getBlobToText('data', filePath + "/" + fileName, onFileReceived); + if (FULL_LOG === true) { logger.write("[INFO] getFile -> filePath = " + filePath); } + if (FULL_LOG === true) { logger.write("[INFO] getFile -> fileName = " + fileName); } - if (CONSOLE_LOG === true) { + try { - console.log("FileCloud -> File Requested -> " + filePath + "/" + fileName); + blobService.getBlobToText('data', filePath + "/" + fileName, onFileReceived); + + } catch (err) { + + if (FULL_LOG === true) { logger.write("[ERROR] getFile -> err = " + err); } } function onFileReceived(err, text, response) { + if (FULL_LOG === true) { logger.write("[INFO] getFile -> onFileReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] getFile -> onFileReceived -> filePath = " + filePath); } + if (FULL_LOG === true) { logger.write("[INFO] getFile -> onFileReceived -> fileName = " + fileName); } + let data; if (err) { - data = JSON.parse("[]"); + if (err.code === "BlobNotFound") { + + let customErr = { + result: GLOBAL.CUSTOM_FAIL_RESPONSE.result, + message: "File does not exist." + }; + + if (FULL_LOG === true) { logger.write("[WARN] getFile -> onFileReceived -> customErr.message = " + customErr.message); } + + callBackFunction(customErr); + return; + } + + if (FULL_LOG === true) { logger.write("[ERROR] getFile -> onFileReceived -> Unexpected Error Ocurred."); } + if (FULL_LOG === true) { logger.write("[ERROR] getFile -> onFileReceived -> err = " + err); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; } else { @@ -96,15 +130,26 @@ function newFileCloud() { data = JSON.parse(text); + if (FULL_LOG === true) { logger.write("[INFO] getFile -> onFileReceived -> Data received is valid JSON."); } + + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, data); + return; + } catch (err) { - data = JSON.parse("[]"); + if (FULL_LOG === true) { logger.write("[WARN] getFile -> onFileReceived -> err = " + err); } + let customErr = { + result: GLOBAL.CUSTOM_OK_RESPONSE.result, + message: "Data not in JSON Format." + }; + + if (FULL_LOG === true) { logger.write("[WARN] getFile -> onFileReceived -> customErr.message = " + customErr.message); } + + callBackFunction(customErr, text); + return; } } - - callBackFunction(data); - } } } \ No newline at end of file diff --git a/Files/FileSequence.js b/Files/FileSequence.js index 9de4e7d2c..e74c90cf8 100644 --- a/Files/FileSequence.js +++ b/Files/FileSequence.js @@ -1,6 +1,11 @@  function newFileSequence() { + const MODULE_NAME = "File Sequence"; + const FULL_LOG = true; + const logger = newDebugLog(); + logger.fileName = MODULE_NAME; + let thisObject = { getFile: getFile, getExpectedFiles: getExpectedFiles, @@ -20,6 +25,9 @@ function newFileSequence() { function initialize(pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + let exchange = ecosystem.getExchange(pProduct, pExchange); if (exchange === undefined) { @@ -35,7 +43,50 @@ function newFileSequence() { fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, "Sequence", onSequenceFileReceived); - function onSequenceFileReceived(file) { + function onSequenceFileReceived(err, file) { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received OK Response."); } + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received FAIL Response."); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } + + case GLOBAL.CUSTOM_OK_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received CUSTOM OK Response."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> err.message = " + err.message); } + + callBackFunction(err); + return; + } + + case GLOBAL.CUSTOM_FAIL_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received CUSTOM FAIL Response."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> err.message = " + err.message); } + + callBackFunction(err); + return; + } + + default: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received Unexpected Response."); } + callBackFunction(err); + return; + } + } maxSequence = Number(file); @@ -45,13 +96,44 @@ function newFileSequence() { fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, i, onFileReceived); - function onFileReceived(file) { + function onFileReceived(err, file) { + + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received OK Response."); } + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received FAIL Response."); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } + + case GLOBAL.CUSTOM_FAIL_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received CUSTOM FAIL Response."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> err.message = " + err.message); } + + callBackFunction(err); + return; + } + + default: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received Unexpected Response."); } + callBackFunction(err); + return; + } + } files.set(i, file); filesLoaded++; - callBackFunction(); // Note that the callback is called for every file loaded. + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); // Note that the callback is called for every file loaded. } } @@ -60,18 +142,25 @@ function newFileSequence() { function getFile(pSequence) { + if (FULL_LOG === true) { logger.write("[INFO] getFile -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] getFile -> pSequence = " + pSequence); } + return files.get(pSequence); } function getExpectedFiles() { + if (FULL_LOG === true) { logger.write("[INFO] getExpectedFiles -> Entering function."); } + return maxSequence + 1; } function getFilesLoaded() { + if (FULL_LOG === true) { logger.write("[INFO] getFilesLoaded -> Entering function."); } + return filesLoaded; } diff --git a/ProductStorage.js b/ProductStorage.js index 8f7d0027d..24d6d86d6 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -1,7 +1,10 @@  function newProductStorage(pName) { - const CONSOLE_LOG = false; + const MODULE_NAME = "Product Storage"; + const FULL_LOG = true; + const logger = newDebugLog(); + logger.fileName = MODULE_NAME; /* @@ -40,15 +43,12 @@ function newProductStorage(pName) { function initialize(pDevTeam, pBot, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + datetime = pDatetime; timePeriod = pTimePeriod; - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } - let dataSetsToLoad = 0; let dataSetsLoaded = 0; @@ -59,68 +59,49 @@ function newProductStorage(pName) { switch (thisSet.type) { case 'Market Files': { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Market Files -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + thisObject.fileCache = newFileCache(); thisObject.fileCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onCacheFileReady); dataSetsToLoad++; - - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize Market Files for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } } break; case 'Daily Files': { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Daily Files -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + thisObject.fileCursorCache = newFileCursorCache(); thisObject.fileCursorCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onFileCursorReady); dataSetsToLoad++; - - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize Daily Files for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } } break; case 'Single File': { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Single File -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + thisObject.file = newFile(); thisObject.file.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onSingleFileReady); dataSetsToLoad++; - - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize Single File for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } } break; case 'File Sequence': { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> File Sequence -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + thisObject.fileSequence = newFileSequence(); thisObject.fileSequence.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady); dataSetsToLoad++; - - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize File Sequence for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } } break; } function onCacheFileReady() { - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize onCacheFileReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } let event = { totalValue: thisObject.fileCache.getExpectedFiles(), @@ -139,11 +120,8 @@ function newProductStorage(pName) { function onFileCursorReady() { - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize onFileCursorReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } let event = { totalValue: thisObject.fileCursorCache.getExpectedFiles(), @@ -162,11 +140,8 @@ function newProductStorage(pName) { function onSingleFileReady() { - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize onSingleFileReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } let event = { totalValue: 1, @@ -183,12 +158,40 @@ function newProductStorage(pName) { } } - function onFileSequenceReady() { + function onFileSequenceReady(err) { - if (CONSOLE_LOG === true) { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } - console.log("Product storage initialize onFileSequenceReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received OK Response."); } + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received FAIL Response."); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } + + case GLOBAL.CUSTOM_FAIL_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received CUSTOM FAIL Response."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> err.message = " + err.message); } + + callBackFunction(err); + return; + } + + default: { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received Unexpected Response."); } + callBackFunction(err); + return; + } } let event = { @@ -208,15 +211,12 @@ function newProductStorage(pName) { function checkInitializeComplete() { - if (CONSOLE_LOG === true) { - - console.log("Product storage initialize checkInitializeComplete for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); - - } + if (FULL_LOG === true) { logger.write("[INFO] checkInitializeComplete -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] checkInitializeComplete -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } if (dataSetsLoaded === dataSetsToLoad) { - callBackFunction(); + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); } } @@ -225,6 +225,8 @@ function newProductStorage(pName) { function setDatetime(pDatetime) { + if (FULL_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); } + /* If there is a change in the day, then we take some actions, otherwise, we dont. */ let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS); @@ -244,6 +246,8 @@ function newProductStorage(pName) { function setTimePeriod(pTimePeriod) { + if (FULL_LOG === true) { logger.write("[INFO] setTimePeriod -> Entering function."); } + /* We are going to filter out the cases in which the timePeriod received is the same that the one we already know. */ if (timePeriod !== pTimePeriod) { diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 1cc135f08..a4fd82ee3 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -9,7 +9,7 @@ changes, then all charts in it are replotted with the corresponging data. function newChartSpace() { const MODULE_NAME = "Chart Space"; - const FULL_LOG = true; + const FULL_LOG = false; const logger = newDebugLog(); logger.fileName = MODULE_NAME; diff --git a/TimelineChart.js b/TimelineChart.js index e50b18b11..1800e6c8a 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -1,7 +1,7 @@ function newTimelineChart() { const MODULE_NAME = "Timeline Chart"; - const FULL_LOG = false; + const FULL_LOG = true; const logger = newDebugLog(); logger.fileName = MODULE_NAME; @@ -100,7 +100,7 @@ storage.initialize(host, competition, onStorageInitialized); - function onStorageInitialized() { + function onStorageInitialized(err) { if (FULL_LOG === true) { logger.write("[INFO] initializeCompetitionPlotters -> onStorageInitialized -> Entering function."); } @@ -208,9 +208,41 @@ storage.initialize(pProductCard.devTeam, pProductCard.bot, pProductCard.product, DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onStorageInitialized) ; - function onStorageInitialized() { + function onStorageInitialized(err) { if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> key = " + pProductCard.devTeam.codeName + "-" + pProductCard.bot.codeName + "-" + pProductCard.product.codeName); } + + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> Received OK Response."); } + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> The plotter will be started."); } + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> Received FAIL Response."); } + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> The plotter will not be started."); } + return; + } + + case GLOBAL.CUSTOM_FAIL_RESPONSE.result: { + + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> Received CUSTOM FAIL Response."); } + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> err.message = " + err.message); } + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> The plotter will not be started."); } + return; + } + + default: { + + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> Received Unexpected Response."); } + if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> The plotter will not be started."); } + return; + } + } /* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */