mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat: Add item information to more node errors (#3681)
* ⚡ Add `itemIndex` to node-thrown errors * ⚡ Add some missing item indexes
This commit is contained in:
@@ -136,17 +136,17 @@ export class Discord implements INodeType {
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
|
||||
if (!body.content && !options.embeds) {
|
||||
throw new NodeOperationError(this.getNode(), 'Either content or embeds must be set.');
|
||||
throw new NodeOperationError(this.getNode(), 'Either content or embeds must be set.', { itemIndex: i });
|
||||
}
|
||||
if (options.embeds) {
|
||||
try {
|
||||
//@ts-expect-error
|
||||
body.embeds = JSON.parse(options.embeds);
|
||||
if (!Array.isArray(body.embeds)) {
|
||||
throw new NodeOperationError(this.getNode(), 'Embeds must be an array of embeds.');
|
||||
throw new NodeOperationError(this.getNode(), 'Embeds must be an array of embeds.', { itemIndex: i });
|
||||
}
|
||||
} catch (e) {
|
||||
throw new NodeOperationError(this.getNode(), 'Embeds must be valid JSON.');
|
||||
throw new NodeOperationError(this.getNode(), 'Embeds must be valid JSON.', { itemIndex: i });
|
||||
}
|
||||
}
|
||||
if (options.username) {
|
||||
@@ -158,7 +158,7 @@ export class Discord implements INodeType {
|
||||
//@ts-expect-error
|
||||
body.components = JSON.parse(options.components);
|
||||
} catch (e) {
|
||||
throw new NodeOperationError(this.getNode(), 'Components must be valid JSON.');
|
||||
throw new NodeOperationError(this.getNode(), 'Components must be valid JSON.', { itemIndex: i });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user