mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
refactor(core): Emit different error for issue in execution or trigger
This commit is contained in:
parent
59a59e0c5f
commit
b36c290d78
|
@ -591,13 +591,20 @@ export interface ITransferNodeTypes {
|
|||
}
|
||||
|
||||
export interface IWorkflowErrorData {
|
||||
[key: string]: IDataObject | string | number | ExecutionError;
|
||||
execution: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[key: string]: any;
|
||||
execution?: {
|
||||
id?: string;
|
||||
url?: string;
|
||||
retryOf?: string;
|
||||
error: ExecutionError;
|
||||
lastNodeExecuted: string;
|
||||
mode: WorkflowExecuteMode;
|
||||
};
|
||||
trigger?: {
|
||||
error: ExecutionError;
|
||||
mode: WorkflowExecuteMode;
|
||||
};
|
||||
workflow: {
|
||||
id?: string;
|
||||
name: string;
|
||||
|
|
|
@ -64,6 +64,7 @@ import {
|
|||
getWorkflowOwner,
|
||||
} from './UserManagement/UserManagementHelper';
|
||||
import { whereClause } from './WorkflowHelpers';
|
||||
import { IWorkflowErrorData } from './Interfaces';
|
||||
|
||||
const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');
|
||||
|
||||
|
@ -91,20 +92,37 @@ export function executeErrorWorkflow(
|
|||
}
|
||||
|
||||
if (fullRunData.data.resultData.error !== undefined) {
|
||||
const workflowErrorData = {
|
||||
execution: {
|
||||
id: executionId,
|
||||
url: pastExecutionUrl,
|
||||
error: fullRunData.data.resultData.error,
|
||||
lastNodeExecuted: fullRunData.data.resultData.lastNodeExecuted!,
|
||||
mode,
|
||||
retryOf,
|
||||
},
|
||||
workflow: {
|
||||
id: workflowData.id !== undefined ? workflowData.id.toString() : undefined,
|
||||
name: workflowData.name,
|
||||
},
|
||||
};
|
||||
let workflowErrorData: IWorkflowErrorData;
|
||||
|
||||
if (executionId) {
|
||||
// The error did happen in an execution
|
||||
workflowErrorData = {
|
||||
execution: {
|
||||
id: executionId,
|
||||
url: pastExecutionUrl,
|
||||
error: fullRunData.data.resultData.error,
|
||||
lastNodeExecuted: fullRunData.data.resultData.lastNodeExecuted!,
|
||||
mode,
|
||||
retryOf,
|
||||
},
|
||||
workflow: {
|
||||
id: workflowData.id !== undefined ? workflowData.id.toString() : undefined,
|
||||
name: workflowData.name,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
// The error did happen in a trigger
|
||||
workflowErrorData = {
|
||||
trigger: {
|
||||
error: fullRunData.data.resultData.error,
|
||||
mode,
|
||||
},
|
||||
workflow: {
|
||||
id: workflowData.id !== undefined ? workflowData.id.toString() : undefined,
|
||||
name: workflowData.name,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Run the error workflow
|
||||
// To avoid an infinite loop do not run the error workflow again if the error-workflow itself failed and it is its own error-workflow.
|
||||
|
|
|
@ -10,7 +10,10 @@ export class WorkflowActivationError extends ExecutionBaseError {
|
|||
constructor(message: string, error: Error, node?: INode) {
|
||||
super(error);
|
||||
this.node = node;
|
||||
this.cause = error;
|
||||
this.cause = {
|
||||
message: error.message,
|
||||
stack: error.stack as string,
|
||||
};
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue