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:
Iván Ovejero
2023-11-27 15:33:21 +01:00
committed by GitHub
parent aae45b043b
commit dff8456382
53 changed files with 758 additions and 694 deletions

View File

@@ -1,11 +1,11 @@
import {
getAllWorkflowExecutionMetadata,
getWorkflowExecutionMetadata,
KV_LIMIT,
setAllWorkflowExecutionMetadata,
setWorkflowExecutionMetadata,
ExecutionMetadataValidationError,
} from '@/WorkflowExecutionMetadata';
setAllWorkflowExecutionMetadata,
KV_LIMIT,
getWorkflowExecutionMetadata,
getAllWorkflowExecutionMetadata,
} from '@/ExecutionMetadata';
import { InvalidExecutionMetadataError } from '@/errors/invalid-execution-metadata.error';
import type { IRunExecutionData } from 'n8n-workflow';
describe('Execution Metadata functions', () => {
@@ -52,7 +52,7 @@ describe('Execution Metadata functions', () => {
} as IRunExecutionData;
expect(() => setWorkflowExecutionMetadata(executionData, 'test1', 1234)).not.toThrow(
ExecutionMetadataValidationError,
InvalidExecutionMetadataError,
);
expect(metadata).toEqual({
@@ -60,7 +60,7 @@ describe('Execution Metadata functions', () => {
});
expect(() => setWorkflowExecutionMetadata(executionData, 'test2', {})).toThrow(
ExecutionMetadataValidationError,
InvalidExecutionMetadataError,
);
expect(metadata).not.toEqual({
@@ -84,7 +84,7 @@ describe('Execution Metadata functions', () => {
test3: 'value3',
test4: 'value4',
}),
).toThrow(ExecutionMetadataValidationError);
).toThrow(InvalidExecutionMetadataError);
expect(metadata).toEqual({
test3: 'value3',
@@ -101,7 +101,7 @@ describe('Execution Metadata functions', () => {
} as IRunExecutionData;
expect(() => setWorkflowExecutionMetadata(executionData, 'te$t1$', 1234)).toThrow(
ExecutionMetadataValidationError,
InvalidExecutionMetadataError,
);
expect(metadata).not.toEqual({