From 5509ba24fdd69bca0d363b2807a28695f8f0dd26 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 9 May 2018 10:21:27 +0200 Subject: [PATCH] Problems with Error handling fixed --- .vs/AAWeb/v15/.suo | Bin 69120 -> 72192 bytes Files/FileCloud.js | 2 +- Files/FileCursor.js | 13 +++++++++++-- ProductStorage.js | 40 ++++++++++++++++++++-------------------- TimelineChart.js | 13 ++++++++++--- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/.vs/AAWeb/v15/.suo b/.vs/AAWeb/v15/.suo index 09a45e0d9ec6ccbccae01d979e697e6c4cf62808..a180a9fdf6ef2dc9954d81121ab4d0a85cd1f34e 100644 GIT binary patch delta 1913 zcmc(eYe*DP6vyX|v-!v!cimMhOV{3;T5AunNXSPT6|`HFJuKH!N-=lab)nR7)5zZF z9NE=~sOg&@M4O5TqBZeLL}Y#m3tEJzpukA659M~QjO(uDhoZ;8Z_c^r-h2LY&pqS3 z$~kXyO@<_vkslSqM57ymjQM;%8l`?tmnoj*&HCieN8k37wHR@3foiszq{0Z>Kpwz} zkQ#CbMnXo(0r<$RAp2mRVwHXuF2pRp0K_p$^foc3!GpcqK;JDA(jH+Vhff-D`4d{c+X!^wyR& zWB{V-t-_@;7^vSVWj6G4F=ylr=VVI@dI2}SB;xrnXcjVHW@`pqYo8C^-8#6wCjqQ& zX>hG$a%_gx{;{`HFSfAI?b5@CI-axvfg)92Sw*S6kiK&qHoL_J1|bf zDJK^%FSoCTK1k9|%`!3ZV+Nx;FSZ^pYT|Lper_xM96lgXg~b7VLJA)_u7{%%%({xo zX@Xbz<5PEUbLYpJCxpUQuZav$6_G4;C72mJ-LIsvT7pTk&BiZb}40 zrBb5~3YVh#N~#|H^DrMA20WQVlHuS(y zw^7P+-DlPJ{H6Nx@ErQUieLJt=&dD=ISnRXuk zG>nHb(_c2Bg`XpNIyMmTJ|}c~;FxRU)Joz#jOQ&<2Ay)ERM69v3D!mxsDv%Q(2m>x zb060Fi_0+otq-Ru>EG-=(HkZ{X5}X9B;pfR`s9uv(=^*tP8|N@{dUvS!Tw&OEfw#w z;s6VS-wcvr@Rc zeV4o44PVCfofbk2gb)p4O;Hp~gd*$}-xekm2Tp1OA79hMI7uIeBui2oG+36F;fm%e z9fF2tl@7uRx0epUR_*?sDuo&c@xcki?@m#Mu|D6@2Xj6v+|t&C;@GSAA}aXsP*u>i zDx89+x_vYPjkZ-9h86z0ZM4bZ$1EZOh_#%!S+5GJVi%BDAH`-25rgOYlssh^p}D9( zZ}k2tg>l*e2_Z$T(7^vDNSKws6AMn{M7zeyg1nsEF=>;XN0yPIW6piq!a_JZT{u9O zz?_NZFAl?}%sEpxY58P#_6^s3(<$BLp$E1@*X$wqoDzUSLBkQRngyd*jE@E)Vl3ne z$6eroJ#-gTW?XEyC>0p^?)1w2rFmu>WN4-tVXV(!?S*JQ2eXxaDCXMWWuBKNEg+V? zaJKG%g_509??Y{(3-4`{YgG?5Um{@=Cs7h35v(@eAKckzh7eDP6)8A^t5)yV-ZAK{ z^nkN$gt-alFY)DtqtZ1_TI8g8PFi9c*@UT?5%7ZvOr>M(H`KM7aZk;%SbFe(4)tKE z1}RzJ9QcOpvi-#ejr2`t2>!FXTzl-H(p#2)Qd`%;4_;d2t2}iu+3~fm1u4__sLw#> Qsr21At)pz(fDowhC#P*7I{*Lx diff --git a/Files/FileCloud.js b/Files/FileCloud.js index 419f2c374..fd172c5a0 100644 --- a/Files/FileCloud.js +++ b/Files/FileCloud.js @@ -109,7 +109,7 @@ function newFileCloud() { if (err) { - if (err.code === "BlobNotFound") { + if (err.code === "BlobNotFound" | err.code === "FileNotFound" | err.code === "ParentNotFound") { let customErr = { result: GLOBAL.CUSTOM_FAIL_RESPONSE.result, diff --git a/Files/FileCursor.js b/Files/FileCursor.js index 3eef33dab..1a716c103 100644 --- a/Files/FileCursor.js +++ b/Files/FileCursor.js @@ -400,8 +400,17 @@ function newFileCursor() { if (INFO_LOG === true) { logger.write("[INFO] getFiles -> onFileReceived -> Received CUSTOM FAIL Response."); } if (INFO_LOG === true) { logger.write("[INFO] getFiles -> onFileReceived -> err.message = " + err.message); } - callBackFunction(err); - return; + if (err.message === "File does not exist.") { + + controlLoop(); + return; + + } else { + + callBackFunction(err); + return; + } + } default: { diff --git a/ProductStorage.js b/ProductStorage.js index 97fb04876..1893beffc 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -75,7 +75,7 @@ function newProductStorage(pName) { if (INFO_LOG === true) { logger.write("[INFO] initialize -> Market Files -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } let marketFiles = newMarketFiles(); - marketFiles.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onCacheFileReady); + marketFiles.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onMarketFileReady); thisObject.marketFiles.push(marketFiles); dataSetsToLoad++; } @@ -86,7 +86,7 @@ function newProductStorage(pName) { if (INFO_LOG === true) { logger.write("[INFO] initialize -> Daily Files -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } let dailyFiles = newDailyFiles(); - dailyFiles.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onFileCursorReady); + dailyFiles.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onDailyFileReady); thisObject.dailyFiles.push(dailyFiles); dataSetsToLoad++; } @@ -115,31 +115,31 @@ function newProductStorage(pName) { break; } - function onCacheFileReady(err, pCaller) { + function onMarketFileReady(err, pCaller) { try { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> Entering function."); } - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Entering function."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } switch (err.result) { case GLOBAL.DEFAULT_OK_RESPONSE.result: { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> Received OK Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Received OK Response."); } break; } case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> Received FAIL Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Received FAIL Response."); } callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); return; } case GLOBAL.CUSTOM_FAIL_RESPONSE.result: { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> Received CUSTOM FAIL Response."); } - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> err.message = " + err.message); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Received CUSTOM FAIL Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> err.message = " + err.message); } callBackFunction(err); return; @@ -147,7 +147,7 @@ function newProductStorage(pName) { default: { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCacheFileReady -> Received Unexpected Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Received Unexpected Response."); } callBackFunction(err); return; } @@ -169,36 +169,36 @@ function newProductStorage(pName) { } catch (err) { - if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onCacheFileReady -> err = " + err); } + if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onMarketFileReady -> err = " + err); } callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } - function onFileCursorReady(err, pCaller) { + function onDailyFileReady(err, pCaller) { try { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> Entering function."); } - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Entering function."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } switch (err.result) { case GLOBAL.DEFAULT_OK_RESPONSE.result: { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> Received OK Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Received OK Response."); } break; } case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> Received FAIL Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Received FAIL Response."); } callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); return; } case GLOBAL.CUSTOM_FAIL_RESPONSE.result: { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> Received CUSTOM FAIL Response."); } - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> err.message = " + err.message); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Received CUSTOM FAIL Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> err.message = " + err.message); } callBackFunction(err); return; @@ -206,7 +206,7 @@ function newProductStorage(pName) { default: { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> Received Unexpected Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Received Unexpected Response."); } callBackFunction(err); return; } @@ -228,7 +228,7 @@ function newProductStorage(pName) { } catch (err) { - if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileCursorReady -> err = " + err); } + if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onDailyFileReady -> err = " + err); } callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/TimelineChart.js b/TimelineChart.js index 767bb192c..6fd38b31c 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -1,7 +1,7 @@ function newTimelineChart() { const MODULE_NAME = "Timeline Chart"; - const INFO_LOG = true; + const INFO_LOG = false; const INTENSIVE_LOG = false; const ERROR_LOG = true; const logger = newDebugLog(); @@ -353,19 +353,26 @@ if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> Received FAIL Response."); } failCounter++; - return; + break; } default: { if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> Received Unexpected Response."); } failCounter++; - return; + break; } } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> initializationCounter = " + initializationCounter); } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> okCounter = " + okCounter); } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> failCounter = " + failCounter); } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> loadingProductCards.length = " + loadingProductCards.length); } + if (initializationCounter === loadingProductCards.length) { // This was the last one. + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> Last Product Loaded."); } + /* If less than 50% of plotters are initialized then we return FAIL. */ if (okCounter >= 1) {