refactor(core): Switch plain errors in cli to ApplicationError (#7857)

Ensure all errors in `cli` are `ApplicationError` or children of it and
contain no variables in the message, to continue normalizing all the
errors we report to Sentry

Follow-up to: https://github.com/n8n-io/n8n/pull/7839
This commit is contained in:
Iván Ovejero
2023-11-29 12:25:10 +01:00
committed by GitHub
parent 87def60979
commit c08c5cc37b
58 changed files with 277 additions and 195 deletions

View File

@@ -26,6 +26,7 @@ import type {
ExecutionError,
} from 'n8n-workflow';
import {
ApplicationError,
ErrorReporterProxy as ErrorReporter,
NodeOperationError,
Workflow,
@@ -679,7 +680,7 @@ export async function getWorkflowData(
parentWorkflowSettings?: IWorkflowSettings,
): Promise<IWorkflowBase> {
if (workflowInfo.id === undefined && workflowInfo.code === undefined) {
throw new Error(
throw new ApplicationError(
'No information about the workflow to execute found. Please provide either the "id" or "code"!',
);
}
@@ -691,7 +692,9 @@ export async function getWorkflowData(
workflowData = await WorkflowsService.get({ id: workflowInfo.id }, { relations });
if (workflowData === undefined || workflowData === null) {
throw new Error(`The workflow with the id "${workflowInfo.id}" does not exist.`);
throw new ApplicationError('Workflow does not exist.', {
extra: { workflowId: workflowInfo.id },
});
}
} else {
workflowData = workflowInfo.code ?? null;