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

@@ -993,19 +993,19 @@ export class HttpRequest implements INodeType {
if (!contentTypesAllowed.includes(options.bodyContentType as string)) {
// As n8n-workflow.NodeHelpers.getParamterResolveOrder can not be changed
// easily to handle parameters in dot.notation simply error for now.
throw new NodeOperationError(this.getNode(), 'Sending binary data is only supported when option "Body Content Type" is set to "RAW/CUSTOM" or "FORM-DATA/MULTIPART"!');
throw new NodeOperationError(this.getNode(), 'Sending binary data is only supported when option "Body Content Type" is set to "RAW/CUSTOM" or "FORM-DATA/MULTIPART"!', { itemIndex });
}
const item = items[itemIndex];
if (item.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 });
}
if (options.bodyContentType === 'raw') {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex) as string;
if (item.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 });
}
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
@@ -1023,7 +1023,7 @@ export class HttpRequest implements INodeType {
propertyName = propertyDataParts[0];
binaryPropertyName = propertyDataParts[1];
} else if (binaryPropertyNames.length > 1) {
throw new NodeOperationError(this.getNode(), 'If more than one property should be send it is needed to define the in the format:<code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2"</code>');
throw new NodeOperationError(this.getNode(), 'If more than one property should be send it is needed to define the in the format:<code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2"</code>', { itemIndex });
}
if (item.binary[binaryPropertyName] === undefined) {
@@ -1061,7 +1061,7 @@ export class HttpRequest implements INodeType {
// @ts-ignore
requestOptions[optionData.name] = JSON.parse(requestOptions[optionData.name]);
} catch (error) {
throw new NodeOperationError(this.getNode(), `The data in "${optionData.displayName}" is no valid JSON. Set Body Content Type to "RAW/Custom" for XML or other types of payloads`);
throw new NodeOperationError(this.getNode(), `The data in "${optionData.displayName}" is no valid JSON. Set Body Content Type to "RAW/Custom" for XML or other types of payloads`, { itemIndex });
}
}
}
@@ -1349,7 +1349,7 @@ export class HttpRequest implements INodeType {
try {
returnItem.body = JSON.parse(returnItem.body);
} catch (error) {
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"');
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex });
}
}
@@ -1364,7 +1364,7 @@ export class HttpRequest implements INodeType {
try {
response = JSON.parse(response);
} catch (error) {
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"');
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex });
}
}