2022-12-21 01:46:26 -08:00
|
|
|
import type { IDataObject } from './Interfaces';
|
2022-06-03 08:25:07 -07:00
|
|
|
import { ExecutionBaseError } from './NodeErrors';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for instantiating an expression error
|
|
|
|
*/
|
|
|
|
export class ExpressionError extends ExecutionBaseError {
|
|
|
|
constructor(
|
|
|
|
message: string,
|
|
|
|
options?: {
|
2022-10-26 02:55:39 -07:00
|
|
|
cause?: Error;
|
2022-06-03 08:25:07 -07:00
|
|
|
causeDetailed?: string;
|
|
|
|
description?: string;
|
2022-07-22 03:19:45 -07:00
|
|
|
descriptionTemplate?: string;
|
2022-09-29 14:02:25 -07:00
|
|
|
failExecution?: boolean;
|
|
|
|
functionality?: 'pairedItem';
|
2022-06-03 08:25:07 -07:00
|
|
|
itemIndex?: number;
|
|
|
|
messageTemplate?: string;
|
2022-09-29 14:02:25 -07:00
|
|
|
nodeCause?: string;
|
2022-06-03 08:25:07 -07:00
|
|
|
parameter?: string;
|
2022-09-29 14:02:25 -07:00
|
|
|
runIndex?: number;
|
|
|
|
type?: string;
|
2022-06-03 08:25:07 -07:00
|
|
|
},
|
|
|
|
) {
|
2022-10-26 02:55:39 -07:00
|
|
|
super(message, { cause: options?.cause });
|
2022-06-03 08:25:07 -07:00
|
|
|
|
|
|
|
if (options?.description !== undefined) {
|
|
|
|
this.description = options.description;
|
|
|
|
}
|
|
|
|
|
2022-09-29 14:02:25 -07:00
|
|
|
this.context.failExecution = !!options?.failExecution;
|
2022-06-03 08:25:07 -07:00
|
|
|
|
2022-09-29 14:02:25 -07:00
|
|
|
const allowedKeys = [
|
|
|
|
'causeDetailed',
|
|
|
|
'descriptionTemplate',
|
|
|
|
'functionality',
|
|
|
|
'itemIndex',
|
|
|
|
'messageTemplate',
|
|
|
|
'nodeCause',
|
|
|
|
'parameter',
|
|
|
|
'runIndex',
|
|
|
|
'type',
|
|
|
|
];
|
|
|
|
if (options !== undefined) {
|
|
|
|
Object.keys(options as IDataObject).forEach((key) => {
|
|
|
|
if (allowedKeys.includes(key)) {
|
|
|
|
this.context[key] = (options as IDataObject)[key];
|
|
|
|
}
|
|
|
|
});
|
2022-06-03 08:25:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-10 05:06:12 -08:00
|
|
|
|
|
|
|
export class ExpressionExtensionError extends ExpressionError {
|
|
|
|
constructor(message: string) {
|
|
|
|
super(message);
|
|
|
|
this.context.failExecution = true;
|
|
|
|
}
|
|
|
|
}
|