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:
Iván Ovejero
2022-07-12 17:51:01 +02:00
committed by GitHub
parent a847190f33
commit 2a8043cd27
117 changed files with 376 additions and 370 deletions

View File

@@ -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 });
}
}