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

@@ -10,7 +10,7 @@ import {
sourceControlFoldersExistCheck,
} from './sourceControlHelper.ee';
import { InstanceSettings } from 'n8n-core';
import { jsonParse } from 'n8n-workflow';
import { ApplicationError, jsonParse } from 'n8n-workflow';
import {
SOURCE_CONTROL_SSH_FOLDER,
SOURCE_CONTROL_GIT_FOLDER,
@@ -150,7 +150,9 @@ export class SourceControlPreferencesService {
validationError: { target: false },
});
if (validationResult.length > 0) {
throw new Error(`Invalid source control preferences: ${JSON.stringify(validationResult)}`);
throw new ApplicationError('Invalid source control preferences', {
extra: { preferences: validationResult },
});
}
return validationResult;
}
@@ -177,7 +179,7 @@ export class SourceControlPreferencesService {
loadOnStartup: true,
});
} catch (error) {
throw new Error(`Failed to save source control preferences: ${(error as Error).message}`);
throw new ApplicationError('Failed to save source control preferences', { cause: error });
}
}
return this.sourceControlPreferences;