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

@@ -2,7 +2,7 @@ import { promises as fs } from 'fs';
import { flags } from '@oclif/command';
import { PLACEHOLDER_EMPTY_WORKFLOW_ID } from 'n8n-core';
import type { IWorkflowBase } from 'n8n-workflow';
import { ExecutionBaseError } from 'n8n-workflow';
import { ApplicationError, ExecutionBaseError } from 'n8n-workflow';
import { ActiveExecutions } from '@/ActiveExecutions';
import { WorkflowRunner } from '@/WorkflowRunner';
@@ -89,7 +89,7 @@ export class Execute extends BaseCommand {
}
if (!workflowData) {
throw new Error('Failed to retrieve workflow data for requested workflow');
throw new ApplicationError('Failed to retrieve workflow data for requested workflow');
}
if (!isWorkflowIdValid(workflowId)) {
@@ -113,7 +113,7 @@ export class Execute extends BaseCommand {
const data = await activeExecutions.getPostExecutePromise(executionId);
if (data === undefined) {
throw new Error('Workflow did not return any data!');
throw new ApplicationError('Workflow did not return any data');
}
if (data.data.resultData.error) {