mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 12:35:46 +03:00
⚡ Display errors in expressions
This commit is contained in:
parent
1e484d5072
commit
9da0c1c884
@ -166,11 +166,11 @@ export default mixins(
|
||||
let returnValue;
|
||||
try {
|
||||
returnValue = this.resolveExpression(`=${variableName}`);
|
||||
} catch (e) {
|
||||
return 'invalid';
|
||||
} catch (error) {
|
||||
return `[invalid (${error.message})]`;
|
||||
}
|
||||
if (returnValue === undefined) {
|
||||
return 'not found';
|
||||
return '[not found]';
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
|
@ -156,7 +156,8 @@ export class Workflow {
|
||||
* @memberof Workflow
|
||||
*/
|
||||
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 {
|
||||
const returnValue = tmpl.tmpl(parameterValue, data);
|
||||
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) {
|
||||
return this.convertObjectValueToString(returnValue);
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
} catch (e) {
|
||||
throw new Error('Expression is not valid.');
|
||||
throw new Error(`Expression is not valid: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user