mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
⚡ Improve continueOnFail behaviour
This commit is contained in:
parent
3bf0a9ab10
commit
ce0aaeba7d
|
@ -249,6 +249,19 @@ export function getNodeParameter(workflow: Workflow, runExecutionData: IRunExecu
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if execution should be continued even if there was an error.
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {INode} node
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function continueOnFail(node: INode): boolean {
|
||||||
|
return get(node, 'continueOnFail', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the webhook URL of the webhook with the given name
|
* Returns the webhook URL of the webhook with the given name
|
||||||
*
|
*
|
||||||
|
@ -474,6 +487,9 @@ export function getExecuteTriggerFunctions(workflow: Workflow, node: INode, addi
|
||||||
export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IExecuteFunctions {
|
export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IExecuteFunctions {
|
||||||
return ((workflow, runExecutionData, connectionInputData, inputData, node) => {
|
return ((workflow, runExecutionData, connectionInputData, inputData, node) => {
|
||||||
return {
|
return {
|
||||||
|
continueOnFail: () => {
|
||||||
|
return continueOnFail(node);
|
||||||
|
},
|
||||||
async executeWorkflow(workflowInfo: IExecuteWorkflowInfo, inputData?: INodeExecutionData[]): Promise<any> { // tslint:disable-line:no-any
|
async executeWorkflow(workflowInfo: IExecuteWorkflowInfo, inputData?: INodeExecutionData[]): Promise<any> { // tslint:disable-line:no-any
|
||||||
return additionalData.executeWorkflow(workflowInfo, additionalData, inputData);
|
return additionalData.executeWorkflow(workflowInfo, additionalData, inputData);
|
||||||
},
|
},
|
||||||
|
@ -559,6 +575,9 @@ export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunEx
|
||||||
export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, itemIndex: number, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IExecuteSingleFunctions {
|
export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, itemIndex: number, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IExecuteSingleFunctions {
|
||||||
return ((workflow, runExecutionData, connectionInputData, inputData, node, itemIndex) => {
|
return ((workflow, runExecutionData, connectionInputData, inputData, node, itemIndex) => {
|
||||||
return {
|
return {
|
||||||
|
continueOnFail: () => {
|
||||||
|
return continueOnFail(node);
|
||||||
|
},
|
||||||
getContext(type: string): IContextObject {
|
getContext(type: string): IContextObject {
|
||||||
return NodeHelpers.getContext(runExecutionData, type, node);
|
return NodeHelpers.getContext(runExecutionData, type, node);
|
||||||
},
|
},
|
||||||
|
|
|
@ -586,9 +586,10 @@ export class HttpRequest implements INodeType {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let response: any; // tslint:disable-line:no-any
|
||||||
const returnItems: INodeExecutionData[] = [];
|
const returnItems: INodeExecutionData[] = [];
|
||||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||||
const options = this.getNodeParameter('options', 0, {}) as IDataObject;
|
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
|
||||||
const url = this.getNodeParameter('url', itemIndex) as string;
|
const url = this.getNodeParameter('url', itemIndex) as string;
|
||||||
|
|
||||||
const fullResponse = !!options.fullResponse as boolean;
|
const fullResponse = !!options.fullResponse as boolean;
|
||||||
|
@ -741,8 +742,17 @@ export class HttpRequest implements INodeType {
|
||||||
requestOptions.json = true;
|
requestOptions.json = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Now that the options are all set make the actual http request
|
// Now that the options are all set make the actual http request
|
||||||
const response = await this.helpers.request(requestOptions);
|
response = await this.helpers.request(requestOptions);
|
||||||
|
} catch (error) {
|
||||||
|
if (this.continueOnFail() === true) {
|
||||||
|
returnItems.push({ json: { error } });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
if (responseFormat === 'file') {
|
if (responseFormat === 'file') {
|
||||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string;
|
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string;
|
||||||
|
|
|
@ -457,12 +457,12 @@ export class NextCloud implements INodeType {
|
||||||
|
|
||||||
let endpoint = '';
|
let endpoint = '';
|
||||||
let requestMethod = '';
|
let requestMethod = '';
|
||||||
|
let responseData: any; // tslint:disable-line:no-any
|
||||||
|
|
||||||
let body: string | Buffer = '';
|
let body: string | Buffer = '';
|
||||||
const headers: IDataObject = {};
|
const headers: IDataObject = {};
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
|
||||||
if (resource === 'file') {
|
if (resource === 'file') {
|
||||||
if (operation === 'download') {
|
if (operation === 'download') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -580,7 +580,16 @@ export class NextCloud implements INodeType {
|
||||||
options.encoding = null;
|
options.encoding = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseData = await this.helpers.request(options);
|
try {
|
||||||
|
responseData = await this.helpers.request(options);
|
||||||
|
} catch (error) {
|
||||||
|
if (this.continueOnFail() === true) {
|
||||||
|
returnData.push({ error });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
if (resource === 'file' && operation === 'download') {
|
if (resource === 'file' && operation === 'download') {
|
||||||
|
|
||||||
|
@ -656,6 +665,7 @@ export class NextCloud implements INodeType {
|
||||||
} else {
|
} else {
|
||||||
returnData.push(responseData as IDataObject);
|
returnData.push(responseData as IDataObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource === 'file' && operation === 'download') {
|
if (resource === 'file' && operation === 'download') {
|
||||||
|
|
|
@ -154,6 +154,7 @@ export interface IExecuteContextData {
|
||||||
|
|
||||||
|
|
||||||
export interface IExecuteFunctions {
|
export interface IExecuteFunctions {
|
||||||
|
continueOnFail(): boolean;
|
||||||
executeWorkflow(workflowInfo: IExecuteWorkflowInfo, inputData?: INodeExecutionData[]): Promise<any>; // tslint:disable-line:no-any
|
executeWorkflow(workflowInfo: IExecuteWorkflowInfo, inputData?: INodeExecutionData[]): Promise<any>; // tslint:disable-line:no-any
|
||||||
getContext(type: string): IContextObject;
|
getContext(type: string): IContextObject;
|
||||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
||||||
|
@ -174,6 +175,7 @@ export interface IExecuteFunctions {
|
||||||
|
|
||||||
|
|
||||||
export interface IExecuteSingleFunctions {
|
export interface IExecuteSingleFunctions {
|
||||||
|
continueOnFail(): boolean;
|
||||||
getContext(type: string): IContextObject;
|
getContext(type: string): IContextObject;
|
||||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
||||||
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData;
|
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData;
|
||||||
|
|
Loading…
Reference in a new issue