mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(Redis Node): Add support for continue on fail / error output branch (#11714)
This commit is contained in:
@@ -4,7 +4,7 @@ import type {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import set from 'lodash/set';
|
||||
|
||||
@@ -521,17 +521,30 @@ export class Redis implements INodeType {
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
const returnItems: INodeExecutionData[] = [];
|
||||
|
||||
try {
|
||||
if (operation === 'info') {
|
||||
if (operation === 'info') {
|
||||
try {
|
||||
const result = await client.info();
|
||||
returnItems.push({ json: convertInfoToObject(result) });
|
||||
} else if (
|
||||
['delete', 'get', 'keys', 'set', 'incr', 'publish', 'push', 'pop'].includes(operation)
|
||||
) {
|
||||
const items = this.getInputData();
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnItems.push({
|
||||
json: {
|
||||
error: error.message,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await client.quit();
|
||||
throw new NodeOperationError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
['delete', 'get', 'keys', 'set', 'incr', 'publish', 'push', 'pop'].includes(operation)
|
||||
) {
|
||||
const items = this.getInputData();
|
||||
|
||||
let item: INodeExecutionData;
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
let item: INodeExecutionData;
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
item = { json: {}, pairedItem: { item: itemIndex } };
|
||||
|
||||
if (operation === 'delete') {
|
||||
@@ -625,14 +638,24 @@ export class Redis implements INodeType {
|
||||
}
|
||||
returnItems.push(item);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnItems.push({
|
||||
json: {
|
||||
error: error.message,
|
||||
},
|
||||
pairedItem: {
|
||||
item: itemIndex,
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
await client.quit();
|
||||
throw new NodeOperationError(this.getNode(), error, { itemIndex });
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} finally {
|
||||
await client.quit();
|
||||
}
|
||||
|
||||
await client.quit();
|
||||
return [returnItems];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user