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

@@ -226,18 +226,18 @@ export class QuickBooks implements INodeType {
const lines = this.getNodeParameter('Line', i) as IDataObject[];
if (!lines.length) {
throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`, { itemIndex: i });
}
if (lines.some(line => line.DetailType === undefined || line.Amount === undefined || line.Description === undefined)) {
throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.');
throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.', { itemIndex: i });
}
lines.forEach(line => {
if (line.DetailType === 'AccountBasedExpenseLineDetail' && line.accountId === undefined) {
throw new NodeOperationError(this.getNode(), 'Please enter an account ID for the associated line.');
throw new NodeOperationError(this.getNode(), 'Please enter an account ID for the associated line.', { itemIndex: i });
} else if (line.DetailType === 'ItemBasedExpenseLineDetail' && line.itemId === undefined) {
throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.');
throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.', { itemIndex: i });
}
});
@@ -317,7 +317,7 @@ export class QuickBooks implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
}
body = populateFields.call(this, body, updateFields, resource);
@@ -389,7 +389,7 @@ export class QuickBooks implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
}
body = populateFields.call(this, body, updateFields, resource);
@@ -460,7 +460,7 @@ export class QuickBooks implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
}
body = populateFields.call(this, body, updateFields, resource);
@@ -488,16 +488,16 @@ export class QuickBooks implements INodeType {
const lines = this.getNodeParameter('Line', i) as IDataObject[];
if (!lines.length) {
throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`, { itemIndex: i });
}
if (lines.some(line => line.DetailType === undefined || line.Amount === undefined || line.Description === undefined)) {
throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.');
throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.', { itemIndex: i });
}
lines.forEach(line => {
if (line.DetailType === 'SalesItemLineDetail' && line.itemId === undefined) {
throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.');
throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.', { itemIndex: i });
}
});
@@ -602,7 +602,7 @@ export class QuickBooks implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
}
body = populateFields.call(this, body, updateFields, resource);
@@ -630,16 +630,16 @@ export class QuickBooks implements INodeType {
const lines = this.getNodeParameter('Line', i) as IDataObject[];
if (!lines.length) {
throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`, { itemIndex: i });
}
if (lines.some(line => line.DetailType === undefined || line.Amount === undefined || line.Description === undefined)) {
throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.');
throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.', { itemIndex: i });
}
lines.forEach(line => {
if (line.DetailType === 'SalesItemLineDetail' && line.itemId === undefined) {
throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.');
throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.', { itemIndex: i });
}
});
@@ -745,7 +745,7 @@ export class QuickBooks implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
}
body = populateFields.call(this, body, updateFields, resource);
@@ -917,7 +917,7 @@ export class QuickBooks implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
}
body = populateFields.call(this, body, updateFields, resource);
@@ -1096,7 +1096,7 @@ export class QuickBooks implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
}
body = populateFields.call(this, body, updateFields, resource);