Error handling improved

This commit is contained in:
Luis Fernando Molina committed 2020-08-03 10:40:58 +02:00
1 parent c777b3cd1f
commit 60a88b781f
3 files changed
+795 -762

No files matched your search

+11 -1
View File
@@ -75,7 +75,17 @@ function newRecordValues() {
let property = productDefinition.record.properties[i]
let value = currentRecord[property.config.codeName]
let targetNode = propertyTargetNodeMap.get(property.id)
applyValue(targetNode[property.config.codeName], value)
/*
If the codeName of the Record Property can not match the name of the property at
the target node, the user can explicitly specify the property name at the configuration,
and in those cases we need to use that. This happens when there are many Record Properties
pointing to the same property at the Target Node.
*/
if (property.config.childProperty !== undefined) {
applyValue(targetNode[property.config.childProperty], value)
} else {
applyValue(targetNode[property.config.codeName], value)
}
}
}
File diff suppressed because it is too large. Load diff
@@ -122,10 +122,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
try {
propertyRootNode = eval(recordProperty.config.nodePath)
} catch (err) {
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> recordProperty.name = " + recordProperty.name);
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> recordProperty.config.nodePath = " + recordProperty.config.nodePath);
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> err.stack = " + err.stack);
throw 'Can not continue with a Definition Error like this.'
badDefinitionUnhandledException(err, 'Error Evaluation Record Property nodePath.', product, recordProperty)
}
}
/*
@@ -137,7 +134,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
try {
targetNode = propertyRootNode[recordProperty.config.codeName]
} catch (err) {
console.log(err.stack)
badDefinitionUnhandledException(err, 'Error setting Target Node.', product, recordProperty)
}
/*
If the codeName of the Record Property can not match the name of the property at
@@ -175,7 +172,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
try {
value = Number(value.toFixed(recordProperty.config.decimals))
} catch (err) {
console.log(err.stack)
badDefinitionUnhandledException(err, 'Error applying configured decimals.', product, recordProperty)
}
}
} else {
@@ -327,4 +324,13 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
}
}
}
function badDefinitionUnhandledException(err, message, product, recordProperty) {
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> " + message);
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> product.name = " + product.name);
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> recordProperty.name = " + recordProperty.name);
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> recordProperty.config.codeName = " + recordProperty.config.codeName);
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> err.stack = " + err.stack);
throw 'Can not continue with a Definition Error like this.'
}
}