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

@@ -38,7 +38,6 @@ import type {
BinaryHelperFunctions,
ConnectionTypes,
ContextType,
ExecutionError,
FieldType,
FileSystemHelperFunctions,
FunctionsBase,
@@ -101,7 +100,7 @@ import {
NodeApiError,
NodeHelpers,
NodeOperationError,
NodeSSLError,
NodeSslError,
OAuth2GrantType,
WorkflowDataProxy,
createDeferredPromise,
@@ -143,7 +142,7 @@ import {
getWorkflowExecutionMetadata,
setAllWorkflowExecutionMetadata,
setWorkflowExecutionMetadata,
} from './WorkflowExecutionMetadata';
} from './ExecutionMetadata';
import { getSecretsProxy } from './Secrets';
import Container from 'typedi';
import type { BinaryData } from './BinaryData/types';
@@ -808,7 +807,7 @@ export async function proxyRequestToAxios(
response: pick(response, ['headers', 'status', 'statusText']),
});
} else if ('rejectUnauthorized' in configObject && error.code?.includes('CERT')) {
throw new NodeSSLError(error);
throw new NodeSslError(error);
}
}
@@ -3442,7 +3441,7 @@ export function getExecuteFunctions(
addInputData(
connectionType: ConnectionTypes,
data: INodeExecutionData[][] | ExecutionError,
data: INodeExecutionData[][] | ExecutionBaseError,
): { index: number } {
const nodeName = this.getNode().name;
let currentNodeRunIndex = 0;
@@ -3473,7 +3472,7 @@ export function getExecuteFunctions(
addOutputData(
connectionType: ConnectionTypes,
currentNodeRunIndex: number,
data: INodeExecutionData[][] | ExecutionError,
data: INodeExecutionData[][] | ExecutionBaseError,
): void {
addExecutionDataFunctions(
'output',