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

@@ -204,7 +204,7 @@ export class HelpScout implements INodeType {
delete body.customerEmail;
}
if (body.customer === undefined) {
throw new NodeOperationError(this.getNode(), 'Either customer email or customer ID must be set');
throw new NodeOperationError(this.getNode(), 'Either customer email or customer ID must be set', { itemIndex: i });
}
if (threads) {
for (let i = 0; i < threads.length; i++) {
@@ -290,7 +290,7 @@ export class HelpScout implements INodeType {
body.websites = websites;
}
if (Object.keys(body).length === 0) {
throw new NodeOperationError(this.getNode(), 'You have to set at least one field');
throw new NodeOperationError(this.getNode(), 'You have to set at least one field', { itemIndex: i });
}
responseData = await helpscoutApiRequest.call(this, 'POST', '/v2/customers', body, qs, undefined, { resolveWithFullResponse: true });
const id = responseData.headers['resource-id'];
@@ -336,7 +336,7 @@ export class HelpScout implements INodeType {
body.age = body.age.toString();
}
if (Object.keys(body).length === 0) {
throw new NodeOperationError(this.getNode(), 'You have to set at least one field');
throw new NodeOperationError(this.getNode(), 'You have to set at least one field', { itemIndex: i });
}
responseData = await helpscoutApiRequest.call(this, 'PUT', `/v2/customers/${customerId}`, body, qs, undefined, { resolveWithFullResponse: true });
responseData = { success: true };
@@ -388,7 +388,7 @@ export class HelpScout implements INodeType {
delete body.customerEmail;
}
if (body.customer === undefined) {
throw new NodeOperationError(this.getNode(), 'Either customer email or customer ID must be set');
throw new NodeOperationError(this.getNode(), 'Either customer email or customer ID must be set', { itemIndex: i });
}
if (attachments) {
if (attachments.attachmentsValues
@@ -407,7 +407,7 @@ export class HelpScout implements INodeType {
mimeType: binaryProperty.mimeType,
};
} else {
throw new NodeOperationError(this.getNode(), `Binary property ${value.property} does not exist on input`);
throw new NodeOperationError(this.getNode(), `Binary property ${value.property} does not exist on input`, { itemIndex: i });
}
};
body.attachments?.push.apply(body.attachments, (attachments.attachmentsBinary as IDataObject[]).map(mapFunction) as IAttachment[]);