mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Reorganize error hierarchy in core and workflow packages (no-changelog) (#7820)
Ensure all errors in `core` and `workflow` inherit from `ApplicationError` so that we start normalizing all the errors we report to Sentry Follow-up to: https://github.com/n8n-io/n8n/pull/7757#discussion_r1404338844 ### `core` package `ApplicationError` - `FileSystemError` (abstract) - `FileNotFoundError` - `DisallowedFilepathError` - `BinaryDataError` (abstract) - `InvalidModeError` - `InvalidManagerError` - `InvalidExecutionMetadataError` ### `workflow` package `ApplicationError` - `ExecutionBaseError` (abstract) - `WorkflowActivationError` - `WorkflowDeactivationError` - `WebhookTakenError` - `WorkflowOperationError` - `SubworkflowOperationError` - `CliWorkflowOperationError` - `ExpressionError` - `ExpressionExtensionError` - `NodeError` (abstract) - `NodeOperationError` - `NodeApiError` - `NodeSSLError` Up next: - Reorganize errors in `cli` - Flatten the hierarchy in `workflow` (do we really need `ExecutionBaseError`?) - Remove `ExecutionError` type - Stop throwing plain `Error`s - Replace `severity` with `level` - Add node and credential types as `tags` - Add workflow IDs and execution IDs as `extras`
This commit is contained in:
34
packages/workflow/src/errors/node-operation.error.ts
Normal file
34
packages/workflow/src/errors/node-operation.error.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { INode } from '..';
|
||||
import type { NodeOperationErrorOptions } from './node-api.error';
|
||||
import { NodeError } from './abstract/node.error';
|
||||
|
||||
/**
|
||||
* Class for instantiating an operational error, e.g. an invalid credentials error.
|
||||
*/
|
||||
export class NodeOperationError extends NodeError {
|
||||
lineNumber: number | undefined;
|
||||
|
||||
constructor(node: INode, error: Error | string, options: NodeOperationErrorOptions = {}) {
|
||||
if (typeof error === 'string') {
|
||||
error = new Error(error);
|
||||
}
|
||||
super(node, error);
|
||||
|
||||
if (options.message) this.message = options.message;
|
||||
if (options.severity) this.severity = options.severity;
|
||||
this.description = options.description;
|
||||
this.context.runIndex = options.runIndex;
|
||||
this.context.itemIndex = options.itemIndex;
|
||||
|
||||
if (this.message === this.description) {
|
||||
this.description = undefined;
|
||||
}
|
||||
|
||||
[this.message, this.description] = this.setDescriptiveErrorMessage(
|
||||
this.message,
|
||||
this.description,
|
||||
undefined,
|
||||
options.messageMapping,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user