mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +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,
|
INodeType,
|
||||||
INodeTypeDescription,
|
INodeTypeDescription,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import { NodeConnectionType } from 'n8n-workflow';
|
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||||
|
|
||||||
import set from 'lodash/set';
|
import set from 'lodash/set';
|
||||||
|
|
||||||
@@ -521,10 +521,22 @@ export class Redis implements INodeType {
|
|||||||
const operation = this.getNodeParameter('operation', 0);
|
const operation = this.getNodeParameter('operation', 0);
|
||||||
const returnItems: INodeExecutionData[] = [];
|
const returnItems: INodeExecutionData[] = [];
|
||||||
|
|
||||||
try {
|
|
||||||
if (operation === 'info') {
|
if (operation === 'info') {
|
||||||
|
try {
|
||||||
const result = await client.info();
|
const result = await client.info();
|
||||||
returnItems.push({ json: convertInfoToObject(result) });
|
returnItems.push({ json: convertInfoToObject(result) });
|
||||||
|
} catch (error) {
|
||||||
|
if (this.continueOnFail()) {
|
||||||
|
returnItems.push({
|
||||||
|
json: {
|
||||||
|
error: error.message,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await client.quit();
|
||||||
|
throw new NodeOperationError(this.getNode(), error);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (
|
} else if (
|
||||||
['delete', 'get', 'keys', 'set', 'incr', 'publish', 'push', 'pop'].includes(operation)
|
['delete', 'get', 'keys', 'set', 'incr', 'publish', 'push', 'pop'].includes(operation)
|
||||||
) {
|
) {
|
||||||
@@ -532,6 +544,7 @@ export class Redis implements INodeType {
|
|||||||
|
|
||||||
let item: INodeExecutionData;
|
let item: INodeExecutionData;
|
||||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||||
|
try {
|
||||||
item = { json: {}, pairedItem: { item: itemIndex } };
|
item = { json: {}, pairedItem: { item: itemIndex } };
|
||||||
|
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
@@ -625,14 +638,24 @@ export class Redis implements INodeType {
|
|||||||
}
|
}
|
||||||
returnItems.push(item);
|
returnItems.push(item);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
if (this.continueOnFail()) {
|
||||||
} finally {
|
returnItems.push({
|
||||||
await client.quit();
|
json: {
|
||||||
|
error: error.message,
|
||||||
|
},
|
||||||
|
pairedItem: {
|
||||||
|
item: itemIndex,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
await client.quit();
|
||||||
|
throw new NodeOperationError(this.getNode(), error, { itemIndex });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await client.quit();
|
||||||
return [returnItems];
|
return [returnItems];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user