Improved error handling for most calculations

This commit is contained in:
Stefan Zermatten
2021-02-12 11:00:44 +02:00
parent fed87f0a84
commit 2b345c1f77
12 changed files with 80 additions and 201 deletions

View File

@@ -4,6 +4,6 @@ export default function embedInlineCalculations(string, calculations){
let index = 0;
return string.replace(/\{([^{}]*)\}/g, () => {
let comp = calculations && calculations[index++];
return comp && comp.result;
return comp && comp.result ? comp.result : string;
});
}

View File

@@ -18,11 +18,6 @@ export default function evaluateString(string, scope, fn = 'compile'){
errors.push(e);
return {result: string, errors};
}
// Parsing failed
if (node === null){
errors.push('...');
return {result: string, errors};
}
let context = new CompilationContext();
let result = node[fn](scope, context);
if (result instanceof ConstantNode){