Improvement at the error handling of conditions / integration with Docs
This commit is contained in:
1 parent
33ca84bb4c
commit
461cdbc267
5 files changed
+216
-15
No files matched your search
@@ -462,6 +462,12 @@
|
||||
"propertyName": "miscellaneousFunctions",
|
||||
"functionName": "newSuperalgosUtilitiesMiscellaneousFunctions",
|
||||
"fileName": "MiscellaneousFunctions.js"
|
||||
},
|
||||
{
|
||||
"name": "Docs Functions",
|
||||
"propertyName": "docsFunctions",
|
||||
"functionName": "newSuperalgosUtilitiesDocsFunctions",
|
||||
"fileName": "DocsFunctions.js"
|
||||
}
|
||||
],
|
||||
"taskModules": [
|
||||
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"topic": "TS LF Trading Bot Errors",
|
||||
"pageNumber": "1",
|
||||
"type": "TS LF Trading Bot Error - Evaluating Condition Error",
|
||||
"definition": {
|
||||
"text": "An error occured while evaluation a User Defined Condition at the Trading System.",
|
||||
"updated": 1611568961215
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "While running at the TS, the Low Frequency Trading Bot encounteren an error while trying to evaluate one of your conditions defined at the Trading System. Conditions are arbitrary Javascript Code that user can write as they want and in some cases they do not write valid Javascript for Nod JS. ",
|
||||
"updated": 1611569329977
|
||||
},
|
||||
{
|
||||
"style": "Error",
|
||||
"text": "Evaluating Condition Error",
|
||||
"updated": 1611569347664
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Error Details"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "In the following section you will find the specific information received when this error occured."
|
||||
},
|
||||
{
|
||||
"style": "Success",
|
||||
"text": "You will only see it if you opened this page as a result of the error actually happening.",
|
||||
"updated": 1611569373599
|
||||
},
|
||||
{
|
||||
"style": "Subtitle",
|
||||
"text": "Error Message"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The following is the Error Message of the Exception that occured at the LF Trading Bot:",
|
||||
"updated": 1611569424352
|
||||
},
|
||||
{
|
||||
"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 LF Trading Bot:",
|
||||
"updated": 1611569434043
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "errorStack"
|
||||
},
|
||||
{
|
||||
"style": "Subtitle",
|
||||
"text": "Error Code"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The follwing is the Error Code of the Exception that occured at the LF Trading Bot:",
|
||||
"updated": 1611569440715
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "errorCode"
|
||||
},
|
||||
{
|
||||
"style": "Subtitle",
|
||||
"text": "Error Details"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The follwing are all the Error details of the Exception that occured at the LF Trading Bot:",
|
||||
"updated": 1611569446711
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "errorDetails"
|
||||
},
|
||||
{
|
||||
"style": "Subtitle",
|
||||
"text": "Node Name",
|
||||
"updated": 1611571361685
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The follwing is the node's name of the Node most related to this error:",
|
||||
"updated": 1611571455498
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "nodeName"
|
||||
},
|
||||
{
|
||||
"style": "Subtitle",
|
||||
"text": "Node Code"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The follwing is the code stored at the node that produced the error at the LF Trading Bot:",
|
||||
"updated": 1611569545869
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "nodeCode",
|
||||
"updated": 1611569590234
|
||||
},
|
||||
{
|
||||
"style": "Subtitle",
|
||||
"text": "Node Config",
|
||||
"updated": 1611569510340
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The follwing is the config stored at the node that produced the error at the LF Trading Bot:",
|
||||
"updated": 1611569573367
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "nodeConfig",
|
||||
"updated": 1611569598109
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
+20
-10
@@ -236,16 +236,19 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) {
|
||||
|
||||
function evalCondition(node) {
|
||||
let value
|
||||
let error
|
||||
let errorMessage
|
||||
let docs
|
||||
/*
|
||||
The code can be at the condition node if it was done with the Conditions Editor, or it can also be
|
||||
at a Javascript Code node. If there is a Javascript object we will give it preference and take the code
|
||||
from there. Otherwise we will take the code from the Condition node.
|
||||
*/
|
||||
let code = node.code
|
||||
let nodeName = node.name
|
||||
if (node.javascriptCode !== undefined) {
|
||||
if (node.javascriptCode.code !== undefined) {
|
||||
code = node.javascriptCode.code
|
||||
nodeName = node.javascriptCode.name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +261,14 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) {
|
||||
will not be considered an error.
|
||||
*/
|
||||
value = false
|
||||
error = err.message
|
||||
errorMessage = err.message
|
||||
docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - Evaluating Condition Error',
|
||||
placeholder: {}
|
||||
}
|
||||
TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, nodeName, code, undefined)
|
||||
}
|
||||
|
||||
tradingSystem.conditions.set(node.id, value)
|
||||
@@ -266,20 +276,20 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) {
|
||||
if (value === true) {
|
||||
tradingSystem.highlights.push(node.id)
|
||||
}
|
||||
if (error !== undefined) {
|
||||
tradingSystem.errors.push([node.id, error])
|
||||
if (errorMessage !== undefined) {
|
||||
tradingSystem.errors.push([node.id, errorMessage, docs])
|
||||
}
|
||||
if (value !== undefined) {
|
||||
tradingSystem.values.push([node.id, value])
|
||||
}
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] evalCondition -> value = ' + value)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] evalCondition -> error = ' + error)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] evalCondition -> errorMessage = ' + errorMessage)
|
||||
}
|
||||
|
||||
function evalFormula(node) {
|
||||
let value
|
||||
let error
|
||||
let errorMessage
|
||||
|
||||
try {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] evalFormula -> ' + node.name + ' -> code = ' + node.code)
|
||||
@@ -290,12 +300,12 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) {
|
||||
will not be considered an error.
|
||||
*/
|
||||
value = 0
|
||||
error = err.message
|
||||
errorMessage = err.message
|
||||
}
|
||||
|
||||
if (error !== undefined) {
|
||||
tradingSystem.errors.push([node.id, error])
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] evalFormula -> error = ' + error)
|
||||
if (errorMessage !== undefined) {
|
||||
tradingSystem.errors.push([node.id, errorMessage])
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[INFO] evalFormula -> errorMessage = ' + errorMessage)
|
||||
return
|
||||
}
|
||||
if (value !== undefined) {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
exports.newSuperalgosUtilitiesDocsFunctions = function () {
|
||||
|
||||
let thisObject = {
|
||||
buildPlaceholder: buildPlaceholder
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function buildPlaceholder(docs, error, nodeName, nodeCode, nodeConfig) {
|
||||
if (error.message !== undefined) {
|
||||
docs.placeholder.errorMessage = {
|
||||
style: 'Error',
|
||||
text: error.message
|
||||
}
|
||||
}
|
||||
if (error.stack !== undefined) {
|
||||
docs.placeholder.errorStack = {
|
||||
style: 'Javascript',
|
||||
text: error.stack
|
||||
}
|
||||
}
|
||||
if (error.nodeCode !== undefined) {
|
||||
docs.placeholder.errorCode = {
|
||||
style: 'Json',
|
||||
text: error.nodeCode
|
||||
}
|
||||
}
|
||||
docs.placeholder.errorDetails = {
|
||||
style: 'Json',
|
||||
text: JSON.stringify(error, undefined, 4)
|
||||
}
|
||||
if (nodeName !== undefined) {
|
||||
docs.placeholder.nodeName = {
|
||||
style: 'Json',
|
||||
text: JSON.stringify(nodeName, undefined, 4)
|
||||
}
|
||||
}
|
||||
if (nodeCode !== undefined) {
|
||||
docs.placeholder.nodeCode = {
|
||||
style: 'Javascript',
|
||||
text: nodeCode
|
||||
}
|
||||
}
|
||||
if (nodeConfig !== undefined) {
|
||||
docs.placeholder.nodeConfig = {
|
||||
style: 'Json',
|
||||
text: JSON.stringify(nodeConfig, undefined, 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,21 +26,22 @@ function newNodesErrors() {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
let arrayItem = array[i]
|
||||
let nodeId = arrayItem[0]
|
||||
let value = arrayItem[1]
|
||||
applyValue(nodeId, value)
|
||||
let errorMessage = arrayItem[1]
|
||||
let docs = arrayItem[2]
|
||||
applyValue(nodeId, errorMessage, docs)
|
||||
}
|
||||
}
|
||||
|
||||
async function applyValue(nodeId, value) {
|
||||
async function applyValue(nodeId, errorMessage, docs) {
|
||||
if (UI.projects.superalgos.spaces.chartingSpace.visible !== true) { return }
|
||||
let node = await UI.projects.superalgos.spaces.designSpace.workspace.getNodeById(nodeId)
|
||||
if (node === undefined) { return }
|
||||
if (node.payload === undefined) { return }
|
||||
if (node.payload.uiObject === undefined) { return }
|
||||
if (value === '') {
|
||||
if (errorMessage === '') {
|
||||
node.payload.uiObject.resetErrorMessage()
|
||||
} else {
|
||||
node.payload.uiObject.setErrorMessage(value, 3)
|
||||
node.payload.uiObject.setErrorMessage(errorMessage, 3, docs)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user