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

@@ -85,4 +85,4 @@ export function tolerateDoubleQuotes(filterQueryParameter: string) {
export function throwOnEmptyUpdate(this: IExecuteFunctions) {
throw new NodeOperationError(this.getNode(), 'Please enter at least one field to update');
}
}

View File

@@ -182,11 +182,11 @@ export class MicrosoftOneDrive implements INodeType {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
}
//@ts-ignore
if (items[i].binary[binaryPropertyName] === undefined) {
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
}
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
@@ -207,7 +207,7 @@ export class MicrosoftOneDrive implements INodeType {
} else {
const body = this.getNodeParameter('fileContent', i) as string;
if (fileName === '') {
throw new NodeOperationError(this.getNode(), 'File name must be set!');
throw new NodeOperationError(this.getNode(), 'File name must be set!', { itemIndex: i });
}
const encodedFilename = encodeURIComponent(fileName);
responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${encodedFilename}:/content`, body, {}, undefined, { 'Content-Type': 'text/plain' });

View File

@@ -270,11 +270,11 @@ export class MicrosoftOutlook implements INodeType {
const binaryPropertyName = attachment.binaryPropertyName as string;
if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
}
//@ts-ignore
if (items[i].binary[binaryPropertyName] === undefined) {
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
}
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
@@ -380,11 +380,11 @@ export class MicrosoftOutlook implements INodeType {
const binaryPropertyName = attachment.binaryPropertyName as string;
if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
}
//@ts-ignore
if (items[i].binary[binaryPropertyName] === undefined) {
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
}
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
@@ -590,11 +590,11 @@ export class MicrosoftOutlook implements INodeType {
const binaryPropertyName = attachment.binaryPropertyName as string;
if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
}
//@ts-ignore
if (items[i].binary[binaryPropertyName] === undefined) {
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
}
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
@@ -644,7 +644,7 @@ export class MicrosoftOutlook implements INodeType {
}
//@ts-ignore
if (items[i].binary[binaryPropertyName] === undefined) {
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
}
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
@@ -653,7 +653,7 @@ export class MicrosoftOutlook implements INodeType {
const fileName = additionalFields.fileName === undefined ? binaryData.fileName : additionalFields.fileName;
if (!fileName) {
throw new NodeOperationError(this.getNode(), 'File name is not set. It has either to be set via "Additional Fields" or has to be set on the binary property!');
throw new NodeOperationError(this.getNode(), 'File name is not set. It has either to be set via "Additional Fields" or has to be set on the binary property!', { itemIndex: i });
}
// Check if the file is over 3MB big

View File

@@ -178,7 +178,7 @@ export class MicrosoftToDo implements INodeType {
} else {
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`);
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i });
}
} else if (resource === 'task') {
@@ -264,7 +264,7 @@ export class MicrosoftToDo implements INodeType {
responseData = await microsoftApiRequest.call(this, 'PATCH', `/todo/lists/${taskListId}/tasks/${taskId}`, body, qs);
} else {
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`);
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i });
}
} else if (resource === 'list') {
@@ -314,7 +314,7 @@ export class MicrosoftToDo implements INodeType {
responseData = await microsoftApiRequest.call(this, 'PATCH', `/todo/lists/${listId}`, body, qs);
} else {
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`);
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i });
}
}
} catch (error) {