diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json new file mode 100644 index 000000000..69e29808e --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json @@ -0,0 +1,64 @@ +{ + "topic": "TS Task Errors", + "pageNumber": "1", + "type": "TS Task Error - Unexpected Error", + "definition": { + "text": "Write here a summary for this topic page." + }, + "paragraphs": [ + { + "style": "Text", + "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." + }, + { + "style": "Error", + "text": "Unexpected Error" + }, + { + "style": "Title", + "text": "Error Message", + "updated": 1610971316249 + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the TS:", + "updated": 1610971326601 + }, + { + "style": "Placeholder", + "text": "errorMessage", + "updated": 1610971337737 + }, + { + "style": "Title", + "text": "Error Stack", + "updated": 1610968600444 + }, + { + "style": "Text", + "text": "The following is the Error Stack of the Exception that occured at the TS:", + "updated": 1610968631281 + }, + { + "style": "Placeholder", + "text": "errorStack", + "updated": 1610968640796 + }, + { + "style": "Title", + "text": "Error Code" + }, + { + "style": "Text", + "text": "The follwing is the Error Code of the Exception that occured at the TS:" + }, + { + "style": "Placeholder", + "text": "errorCode" + }, + { + "style": "Text", + "text": "" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/SingleMarketIndicatorBot.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/SingleMarketIndicatorBot.js index 887e3ea3a..383a87778 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/SingleMarketIndicatorBot.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/SingleMarketIndicatorBot.js @@ -818,6 +818,8 @@ } } catch (err) { + TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR = err + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] run -> err = " + err.stack); clearTimeout(nextLoopTimeoutHandle); diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/SingleMarketSensorBot.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/SingleMarketSensorBot.js index cfa60ada6..a807b955c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/SingleMarketSensorBot.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/SingleMarketSensorBot.js @@ -576,6 +576,8 @@ } catch (err) { + TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR = err + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] run -> err = " + err.stack); clearTimeout(nextLoopTimeoutHandle); diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/SingleMarketTradingBot.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/SingleMarketTradingBot.js index 372b0967c..9d6da5c2b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/SingleMarketTradingBot.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/SingleMarketTradingBot.js @@ -713,6 +713,8 @@ } } catch (err) { + TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR = err + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] run -> err = " + err.stack); clearTimeout(nextLoopTimeoutHandle); diff --git a/Projects/Superalgos/TS/Function-Libraries/NodeJSFunctions.js b/Projects/Superalgos/TS/Function-Libraries/NodeJSFunctions.js index 4648486e2..14530bac6 100644 --- a/Projects/Superalgos/TS/Function-Libraries/NodeJSFunctions.js +++ b/Projects/Superalgos/TS/Function-Libraries/NodeJSFunctions.js @@ -9,18 +9,48 @@ exports.newSuperalgosFunctionLibrariesNodeJSFunctions = function () { function exitProcess() { + let uiError + if (TS.projects.superalgos.globals.taskVariables.FATAL_ERROR_MESSAGE !== undefined) { - TS.projects.superalgos.functionLibraries.taskFunctions.taskError( - undefined, - "An unexpected error caused the Task to stop. " + TS.projects.superalgos.globals.taskVariables.FATAL_ERROR_MESSAGE, - { - project: 'Superalgos', - category: 'Topic', - type: 'TS Task Error - Unexpected Error' - } - ) + uiError = "An unexpected error caused the Task to stop. " + TS.projects.superalgos.globals.taskVariables.FATAL_ERROR_MESSAGE + } else { + uiError = "An unexpected error caused the Task to stop." } + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'TS Task Error - Unexpected Error', + placeholder: {} + } + + if (TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR !== undefined) { + if (TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.message !== undefined) { + docs.placeholder.errorMessage = { + style: 'Error', + text: TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.message + } + } + if (TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.stack !== undefined) { + docs.placeholder.errorStack = { + style: 'Javascript', + text: TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.stack + } + } + if (TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.code !== undefined) { + docs.placeholder.errorCode = { + style: 'Json', + text: TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.code + } + } + } + + TS.projects.superalgos.functionLibraries.taskFunctions.taskError( + undefined, + uiError, + docs + ) + if (isNodeJsProcessShuttingDown === true) { return } isNodeJsProcessShuttingDown = true diff --git a/Projects/Superalgos/TS/Function-Libraries/TaskFunctions.js b/Projects/Superalgos/TS/Function-Libraries/TaskFunctions.js index 6fd9cdabb..18f29d325 100644 --- a/Projects/Superalgos/TS/Function-Libraries/TaskFunctions.js +++ b/Projects/Superalgos/TS/Function-Libraries/TaskFunctions.js @@ -19,7 +19,8 @@ exports.newSuperalgosFunctionLibrariesTaskFunctions = function () { } } else { event = { - errorMessage: errorMessage + errorMessage: errorMessage, + docs: docs } } let key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.name + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.type + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.id diff --git a/Projects/Superalgos/TS/Globals/TaskVariables.js b/Projects/Superalgos/TS/Globals/TaskVariables.js index a51d1646f..caf9039d5 100644 --- a/Projects/Superalgos/TS/Globals/TaskVariables.js +++ b/Projects/Superalgos/TS/Globals/TaskVariables.js @@ -5,9 +5,10 @@ exports.newSuperalgosGlobalsTaskVariables = function () { */ let thisObject = { IS_TASK_STOPPING: false, - LOGGER_MAP: new Map(), // We will put all the loggers in a map, so that we can eventually finalize them. - SESSION_MAP: new Map(), // We will put all the sessions in a map, so that we can eventually finalize them. - FATAL_ERROR_MESSAGE: undefined + LOGGER_MAP: new Map(), // We will put all the loggers in a map, so that we can eventually finalize them. + SESSION_MAP: new Map(), // We will put all the sessions in a map, so that we can eventually finalize them. + FATAL_ERROR_MESSAGE: undefined, + UNEXPECTED_ERROR: undefined, // This is where we store the latest unexpected task error. } return thisObject diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 3b2391304..590dbf65f 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -61,7 +61,7 @@ function newSuperalgosDocSpace() { setUpMenuItemsMap() setupUserLanguage() setupActiveBranch() - setupContributionsBranch() + setupContributionsBranch() thisObject.searchEngine = newSuperalgosDocsSearchEngine() thisObject.mainSearchPage = newSuperalgosDocsMainSearchPage() @@ -186,7 +186,7 @@ function newSuperalgosDocSpace() { function changeActiveBranch(branch) { httpRequest(undefined, 'App/Checkout/' + branch, onResponse) UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Changing Current Branch') - + function onResponse(err, data) { /* Lets check the result of the call through the http interface */ data = JSON.parse(data) @@ -250,7 +250,9 @@ function newSuperalgosDocSpace() { UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project, UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category, UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type, - UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.anchor + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.anchor, + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.nodeId, + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.placeholder ) } } @@ -269,19 +271,19 @@ function newSuperalgosDocSpace() { } } - function openSpaceAreaAndNavigateTo(project, category, type, anchor, nodeId) { + function openSpaceAreaAndNavigateTo(project, category, type, anchor, nodeId, placeholder) { - getReadyToNavigate(project, category, type, anchor, nodeId) + getReadyToNavigate(project, category, type, anchor, nodeId, placeholder) thisObject.sidePanelTab.open() } - function navigateTo(project, category, type, anchor, nodeId) { + function navigateTo(project, category, type, anchor, nodeId, placeholder) { EDITOR_ON_FOCUS = false // forced exit UI.projects.superalgos.spaces.docsSpace.paragraphMap = new Map() - getReadyToNavigate(project, category, type, anchor, nodeId) + getReadyToNavigate(project, category, type, anchor, nodeId, placeholder) UI.projects.superalgos.spaces.docsSpace.documentPage.render() @@ -296,16 +298,10 @@ function newSuperalgosDocSpace() { } } - function getReadyToNavigate(project, category, type, anchor, nodeId) { + function getReadyToNavigate(project, category, type, anchor, nodeId, placeholder) { /* Replace the current object with this */ if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered !== undefined) { - UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered = { - project: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project, - category: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category, - type: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type, - anchor: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.anchor, - nodeId: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.nodeId - } + UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered = JSON.parse(JSON.stringify(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered)) } if (category === 'Book') { @@ -314,7 +310,8 @@ function newSuperalgosDocSpace() { category: category, type: type.replace('AMPERSAND', '\''), anchor: anchor, - nodeId: nodeId + nodeId: nodeId, + placeholder: placeholder } } @@ -323,7 +320,8 @@ function newSuperalgosDocSpace() { category: category, type: type.replace('AMPERSAND', '\''), anchor: anchor, - nodeId: nodeId + nodeId: nodeId, + placeholder: placeholder } } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js index e9f75ac3f..04df22800 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js @@ -170,85 +170,7 @@ function newSuperalgosDocsDocumentPage() { HTML = HTML + '' // Clickeable Container Ends - - if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Topic') { - - orderedTopicPageIndexArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex( - UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project, - 'Topic', - thisObject.docsSchemaDocument.topic - ) - - /* Topic Title - - titleLabel = thisObject.docsSchemaDocument.topic + ' Topic Navigation' - HTML = HTML + '
You just read page ' + thisObject.docsSchemaDocument.pageNumber + ' in the topic.
' - - generateTopicMultiPageIndex() - - HTML = HTML + 'You just did step ' + thisObject.docsSchemaDocument.pageNumber + ' in the tutorial.
' - - generateTutorialMultiPageIndex() - - HTML = HTML + 'You just read page ' + thisObject.docsSchemaDocument.pageNumber + ' of this review collection.
' - - generateReviewMultiPageIndex() - - HTML = HTML + 'You just read page ' + thisObject.docsSchemaDocument.pageNumber + ' in the topic.
' + + generateTopicMultiPageIndex() + + HTML = HTML + 'You just did step ' + thisObject.docsSchemaDocument.pageNumber + ' in the tutorial.
' + + generateTutorialMultiPageIndex() + + HTML = HTML + 'You just read page ' + thisObject.docsSchemaDocument.pageNumber + ' of this review collection.
' + + generateReviewMultiPageIndex() + + HTML = HTML + '