diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-001-ts-api-data-fetcher-bot-error-api-map-reference-node-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-001-ts-api-data-fetcher-bot-error-api-map-reference-node-missing.json new file mode 100644 index 000000000..c5b1499d9 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-001-ts-api-data-fetcher-bot-error-api-map-reference-node-missing.json @@ -0,0 +1,101 @@ +{ + "topic": "TS API Data Fetcher Bot Error", + "pageNumber": "1", + "type": "TS API Data Fetcher Bot Error - API Map Reference Node Missing", + "definition": { + "text": "The node where this error occured needs to have a child of type API Map Reference referencing the API Map. This API Map will tell the bot how to locate the API Server and how to extract data from it.", + "updated": 1621859784437 + }, + "paragraphs": [ + { + "style": "Error", + "text": "API Map Reference Node Missing", + "updated": 1621860374194 + }, + { + "style": "Title", + "text": "Error Info" + }, + { + "style": "Text", + "text": "In the following section, you will find the information recorded when the error occurred." + }, + { + "style": "Text", + "text": "You will only see the information if you opened this page as a result of the error actually occurring.", + "updated": 1611680880668 + }, + { + "style": "Subtitle", + "text": "Error Message" + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorMessage" + }, + { + "style": "Subtitle", + "text": "Error Stack" + }, + { + "style": "Text", + "text": "The following is the Error Stack of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorStack" + }, + { + "style": "Subtitle", + "text": "Error Code" + }, + { + "style": "Text", + "text": "The following is the Error Code of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorCode" + }, + { + "style": "Subtitle", + "text": "Error Details" + }, + { + "style": "Text", + "text": "The following are all the Error details of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorDetails" + }, + { + "style": "Subtitle", + "text": "Node Name" + }, + { + "style": "Text", + "text": "The following is the node's name of the Node most related to this error:" + }, + { + "style": "Placeholder", + "text": "nodeName" + }, + { + "style": "Subtitle", + "text": "Node Code" + }, + { + "style": "Text", + "text": "The following is the code stored at the node that produced the error at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "nodeCode" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-001-ts-api-data-fetcher-bot-error-reference-parent-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-001-ts-api-data-fetcher-bot-error-reference-parent-missing.json new file mode 100644 index 000000000..84686089f --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-001-ts-api-data-fetcher-bot-error-reference-parent-missing.json @@ -0,0 +1,101 @@ +{ + "topic": "TS API Data Fetcher Bot Error", + "pageNumber": "1", + "type": "TS API Data Fetcher Bot Error - Reference Parent Missing", + "definition": { + "text": "The node where this error occured needs to have a Reference Parent. Establish a reference from this node and this error will not happen again.", + "updated": 1621860822884 + }, + "paragraphs": [ + { + "style": "Error", + "text": "Reference Parent Missing", + "updated": 1621860374194 + }, + { + "style": "Title", + "text": "Error Info" + }, + { + "style": "Text", + "text": "In the following section, you will find the information recorded when the error occurred." + }, + { + "style": "Text", + "text": "You will only see the information if you opened this page as a result of the error actually occurring.", + "updated": 1611680880668 + }, + { + "style": "Subtitle", + "text": "Error Message" + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorMessage" + }, + { + "style": "Subtitle", + "text": "Error Stack" + }, + { + "style": "Text", + "text": "The following is the Error Stack of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorStack" + }, + { + "style": "Subtitle", + "text": "Error Code" + }, + { + "style": "Text", + "text": "The following is the Error Code of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorCode" + }, + { + "style": "Subtitle", + "text": "Error Details" + }, + { + "style": "Text", + "text": "The following are all the Error details of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorDetails" + }, + { + "style": "Subtitle", + "text": "Node Name" + }, + { + "style": "Text", + "text": "The following is the node's name of the Node most related to this error:" + }, + { + "style": "Placeholder", + "text": "nodeName" + }, + { + "style": "Subtitle", + "text": "Node Code" + }, + { + "style": "Text", + "text": "The following is the code stored at the node that produced the error at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "nodeCode" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-002-ts-api-data-fetcher-bot-error-reference-parent-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-002-ts-api-data-fetcher-bot-error-reference-parent-missing.json new file mode 100644 index 000000000..6342ecdb1 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-api-data-fetcher-bot-error-002-ts-api-data-fetcher-bot-error-reference-parent-missing.json @@ -0,0 +1,101 @@ +{ + "topic": "TS API Data Fetcher Bot Error", + "pageNumber": "1", + "type": "TS API Data Fetcher Bot Error - Reference Parent Missing", + "definition": { + "text": "The node where this error occured needs to have a child of type API Map Reference referencing the API Map. This API Map will tell the bot how to locate the API Server and how to extract data from it.", + "updated": 1621859784437 + }, + "paragraphs": [ + { + "style": "Error", + "text": "Reference Parent Missing", + "updated": 1621860374194 + }, + { + "style": "Title", + "text": "Error Info" + }, + { + "style": "Text", + "text": "In the following section, you will find the information recorded when the error occurred." + }, + { + "style": "Text", + "text": "You will only see the information if you opened this page as a result of the error actually occurring.", + "updated": 1611680880668 + }, + { + "style": "Subtitle", + "text": "Error Message" + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorMessage" + }, + { + "style": "Subtitle", + "text": "Error Stack" + }, + { + "style": "Text", + "text": "The following is the Error Stack of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorStack" + }, + { + "style": "Subtitle", + "text": "Error Code" + }, + { + "style": "Text", + "text": "The following is the Error Code of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorCode" + }, + { + "style": "Subtitle", + "text": "Error Details" + }, + { + "style": "Text", + "text": "The following are all the Error details of the Exception that occured at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "errorDetails" + }, + { + "style": "Subtitle", + "text": "Node Name" + }, + { + "style": "Text", + "text": "The following is the node's name of the Node most related to this error:" + }, + { + "style": "Placeholder", + "text": "nodeName" + }, + { + "style": "Subtitle", + "text": "Node Code" + }, + { + "style": "Text", + "text": "The following is the code stored at the node that produced the error at the API Data Fetcher Bot:" + }, + { + "style": "Placeholder", + "text": "nodeCode" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js b/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js index a7a1601d6..c59688cc9 100644 --- a/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js @@ -15,23 +15,6 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { function initialize(pStatusDependencies, callBackFunction) { try { - - const message = 'Announcement Condition Evaluation Error' - let err = { - message: message - } - let docs = { - project: 'Superalgos', - category: 'Topic', - type: 'TS LF Trading Bot Error - ' + message, - placeholder: {} - } - - TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, undefined, undefined, undefined, undefined, undefined) - err.docs = docs - err.node = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex] - - throw (err) statusDependencies = pStatusDependencies; callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { @@ -94,14 +77,20 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { processNode = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].apiMapReference === undefined) { - // TODO Error Handling - return + throwHandledException( + undefined, + 'API Map Reference Node Missing', + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex] + ) } let apiMap = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].apiMapReference.referenceParent if (apiMap === undefined) { - // TODO Error Handling - return + throwHandledException( + undefined, + 'Reference Parent Missing', + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].apiMapReference + ) } let hostName @@ -894,4 +883,41 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } -}; + function throwHandledException( + err, + message, + node + ) { + if (err === undefined) { + err = { + message: message + } + } + /* + This is what the Docs Space will get. + */ + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'TS API Data Fetcher Bot Error - ' + message, + placeholder: {} + } + TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder( + docs, + err, + node.name, + node.code, + node.config, + node.value, + err + ) + /* + This will be needed for the process level error handling. Must be added + here after the buildPlaceholder function call. + */ + err.docs = docs + err.node = node + + throw (err) + } +} diff --git a/Projects/Superalgos/TS/Task-Modules/DebugLog.js b/Projects/Superalgos/TS/Task-Modules/DebugLog.js index feb23a57f..566bbe084 100644 --- a/Projects/Superalgos/TS/Task-Modules/DebugLog.js +++ b/Projects/Superalgos/TS/Task-Modules/DebugLog.js @@ -50,20 +50,20 @@ exports.newSuperalgosTaskModulesDebugLog = function (processIndex) { " " + strPad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName, 20) + " " + - strPad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName, 40) + + strPad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName, 30) + " " + strPad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName, 40) + loopType + strPad(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).MAIN_LOOP_COUNTER, 8) + " " + - strPad(date, 30) + + strPad(date, 28) + " " + - strPad(percentage, 10) + strPad(percentage, 8) ) } function newMainLoop() { - logLoop('', '', " Main Loop # ") + logLoop('', '', " Main Loop # ") } function newInternalLoop(date, percentage) { @@ -76,7 +76,7 @@ exports.newSuperalgosTaskModulesDebugLog = function (processIndex) { if (date === undefined) { date = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_DATETIME } date = date.getUTCFullYear() + '-' + strPad(date.getUTCMonth() + 1, 2, "0") + '-' + strPad(date.getUTCDate(), 2, "0"); - logLoop(date, percentage, " Internal Loop # ") + logLoop(date, percentage, " Internal Loop # ") persist(); } diff --git a/Projects/Superalgos/TS/Utilities/DocsFunctions.js b/Projects/Superalgos/TS/Utilities/DocsFunctions.js index 158a3be5c..e71e448ae 100644 --- a/Projects/Superalgos/TS/Utilities/DocsFunctions.js +++ b/Projects/Superalgos/TS/Utilities/DocsFunctions.js @@ -6,7 +6,15 @@ exports.newSuperalgosUtilitiesDocsFunctions = function () { return thisObject - function buildPlaceholder(docs, error, nodeName, nodeCode, nodeConfig, nodeValue, contextInfo) { + function buildPlaceholder( + docs, + error, + nodeName, + nodeCode, + nodeConfig, + nodeValue, + contextInfo + ) { if (error !== undefined) { if (error.message !== undefined) { docs.placeholder.errorMessage = {