mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
⚡ Display errors in expressions
This commit is contained in:
parent
1e484d5072
commit
9da0c1c884
|
@ -166,11 +166,11 @@ export default mixins(
|
||||||
let returnValue;
|
let returnValue;
|
||||||
try {
|
try {
|
||||||
returnValue = this.resolveExpression(`=${variableName}`);
|
returnValue = this.resolveExpression(`=${variableName}`);
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
return 'invalid';
|
return `[invalid (${error.message})]`;
|
||||||
}
|
}
|
||||||
if (returnValue === undefined) {
|
if (returnValue === undefined) {
|
||||||
return 'not found';
|
return '[not found]';
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
|
|
@ -156,7 +156,8 @@ export class Workflow {
|
||||||
* @memberof Workflow
|
* @memberof Workflow
|
||||||
*/
|
*/
|
||||||
convertObjectValueToString(value: object): string {
|
convertObjectValueToString(value: object): string {
|
||||||
return `[Object: ${JSON.stringify(value)}]`;
|
const typeName = Array.isArray(value) ? 'Array' : 'Object';
|
||||||
|
return `[${typeName}: ${JSON.stringify(value)}]`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -906,18 +907,13 @@ export class Workflow {
|
||||||
try {
|
try {
|
||||||
const returnValue = tmpl.tmpl(parameterValue, data);
|
const returnValue = tmpl.tmpl(parameterValue, data);
|
||||||
if (returnValue !== null && typeof returnValue === 'object') {
|
if (returnValue !== null && typeof returnValue === 'object') {
|
||||||
if (Object.keys(returnValue).length === 0) {
|
|
||||||
// When expression is incomplete it returns a Proxy which causes problems.
|
|
||||||
// Catch it with this code and return a proper error.
|
|
||||||
throw new Error('Expression is not valid.');
|
|
||||||
}
|
|
||||||
if (returnObjectAsString === true) {
|
if (returnObjectAsString === true) {
|
||||||
return this.convertObjectValueToString(returnValue);
|
return this.convertObjectValueToString(returnValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Expression is not valid.');
|
throw new Error(`Expression is not valid: ${e.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue