n8n/packages/nodes-base/nodes/Code/throw-execution-error.ts
Tomi Turtiainen eb355df6c2
refactor: Replace deprecated ApplicationError in remaining nodes-base nodes (no-changelog) (#32473)
Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
2026-06-17 18:19:46 +00:00

16 lines
522 B
TypeScript

import { UnexpectedError } from 'n8n-workflow';
import { isWrappableError, WrappedExecutionError } from './errors/WrappedExecutionError';
export function throwExecutionError(error: unknown): never {
if (error instanceof Error) {
throw error;
} else if (isWrappableError(error)) {
// The error coming from task runner is not an instance of error,
// so we need to wrap it in an error instance.
throw new WrappedExecutionError(error);
}
throw new UnexpectedError(`Unknown error: ${JSON.stringify(error)}`);
}