2023-01-27 05:56:56 -08:00
|
|
|
import type { INode } from './Interfaces';
|
2023-09-27 07:57:52 -07:00
|
|
|
import { ExecutionBaseError, type Severity } from './NodeErrors';
|
2022-06-06 00:17:35 -07:00
|
|
|
|
2022-10-26 02:55:39 -07:00
|
|
|
interface WorkflowActivationErrorOptions {
|
|
|
|
cause?: Error;
|
|
|
|
node?: INode;
|
2023-09-27 07:57:52 -07:00
|
|
|
severity?: Severity;
|
2023-11-07 04:48:48 -08:00
|
|
|
workflowId?: string;
|
2022-10-26 02:55:39 -07:00
|
|
|
}
|
|
|
|
|
2022-06-06 00:17:35 -07:00
|
|
|
/**
|
|
|
|
* Class for instantiating an workflow activation error
|
|
|
|
*/
|
|
|
|
export class WorkflowActivationError extends ExecutionBaseError {
|
|
|
|
node: INode | undefined;
|
|
|
|
|
2023-11-07 04:48:48 -08:00
|
|
|
workflowId: string | undefined;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
message: string,
|
|
|
|
{ cause, node, severity, workflowId }: WorkflowActivationErrorOptions = {},
|
|
|
|
) {
|
2022-10-26 02:55:39 -07:00
|
|
|
let error = cause as Error;
|
|
|
|
if (cause instanceof ExecutionBaseError) {
|
|
|
|
error = new Error(cause.message);
|
|
|
|
error.constructor = cause.constructor;
|
|
|
|
error.name = cause.name;
|
|
|
|
error.stack = cause.stack;
|
|
|
|
}
|
|
|
|
super(message, { cause: error });
|
2022-06-06 00:17:35 -07:00
|
|
|
this.node = node;
|
2023-11-07 04:48:48 -08:00
|
|
|
this.workflowId = workflowId;
|
2022-06-06 00:17:35 -07:00
|
|
|
this.message = message;
|
2023-09-27 07:57:52 -07:00
|
|
|
if (severity) this.severity = severity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-07 04:48:48 -08:00
|
|
|
export class WorkflowDeactivationError extends WorkflowActivationError {}
|
|
|
|
|
2023-09-27 07:57:52 -07:00
|
|
|
export class WebhookPathAlreadyTakenError extends WorkflowActivationError {
|
|
|
|
constructor(nodeName: string, cause?: Error) {
|
|
|
|
super(
|
|
|
|
`The URL path that the "${nodeName}" node uses is already taken. Please change it to something else.`,
|
|
|
|
{ severity: 'warning', cause },
|
|
|
|
);
|
2022-06-06 00:17:35 -07:00
|
|
|
}
|
|
|
|
}
|