n8n/packages/workflow/src/ExpressionError.ts
Iván Ovejero 1197811a1e fix(core)!: Allow syntax errors and expression errors to fail executions (#6352)
* fix: Unify expression error behavior for v1

* fix: Add `package.json` to `tsconfig.build.json`

* fix: Make `isFrontend` a constant

* fix: Use CommonJS require to read version

* fix: Use `JSON.parse()` and `fs.readFileSync()`

* feat(editor): Make WF name a link on /executions (#6354)

* make wf name a link in exec view

* link color

* make wf name a link in exec view

* link color

---------

Co-authored-by: Alex Grozav <alex@grozav.com>

* fix: Try restoring inclusions in tsconfig files

* fix: Try with copy

* refactor: Switch base branch and remove global toggle

* chore: Remove unrelated changes

* chore: Restore lockfile

* fix: Ensure all expression errors fail executions

* uncaught ExpressionErrors should not fail e2e tests

---------

Co-authored-by: romainminaud <romain.minaud@gmail.com>
Co-authored-by: Alex Grozav <alex@grozav.com>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2023-06-22 21:04:59 +02:00

52 lines
1.1 KiB
TypeScript

import type { IDataObject } from './Interfaces';
import { ExecutionBaseError } from './NodeErrors';
/**
* Class for instantiating an expression error
*/
export class ExpressionError extends ExecutionBaseError {
constructor(
message: string,
options?: {
cause?: Error;
causeDetailed?: string;
description?: string;
descriptionTemplate?: string;
functionality?: 'pairedItem';
itemIndex?: number;
messageTemplate?: string;
nodeCause?: string;
parameter?: string;
runIndex?: number;
type?: string;
},
) {
super(message, { cause: options?.cause });
if (options?.description !== undefined) {
this.description = options.description;
}
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];
}
});
}
}
}
export class ExpressionExtensionError extends ExpressionError {}