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

@@ -6,7 +6,7 @@ import type {
WorkflowActivateMode,
WorkflowExecuteMode,
} from 'n8n-workflow';
import { WebhookPathTakenError } from 'n8n-workflow';
import { ApplicationError, WebhookPathTakenError } from 'n8n-workflow';
import * as NodeExecuteFunctions from 'n8n-core';
@Service()
@@ -32,7 +32,9 @@ export class ActiveWebhooks {
activation: WorkflowActivateMode,
): Promise<void> {
if (workflow.id === undefined) {
throw new Error('Webhooks can only be added for saved workflows as an id is needed!');
throw new ApplicationError(
'Webhooks can only be added for saved workflows as an ID is needed',
);
}
if (webhookData.path.endsWith('/')) {
webhookData.path = webhookData.path.slice(0, -1);