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

@@ -35,6 +35,7 @@ import { InternalHooks } from '@/InternalHooks';
import { TagRepository } from '@db/repositories/tag.repository';
import { Logger } from '@/Logger';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { ApplicationError } from 'n8n-workflow';
@Service()
export class SourceControlService {
@@ -83,7 +84,7 @@ export class SourceControlService {
false,
);
if (!foldersExisted) {
throw new Error();
throw new ApplicationError('No folders exist');
}
if (!this.gitService.git) {
await this.initGitService();
@@ -94,7 +95,7 @@ export class SourceControlService {
branches.current !==
this.sourceControlPreferencesService.sourceControlPreferences.branchName
) {
throw new Error();
throw new ApplicationError('Branch is not set up correctly');
}
} catch (error) {
throw new BadRequestError(
@@ -195,7 +196,7 @@ export class SourceControlService {
await this.gitService.pull();
} catch (error) {
this.logger.error(`Failed to reset workfolder: ${(error as Error).message}`);
throw new Error(
throw new ApplicationError(
'Unable to fetch updates from git - your folder might be out of sync. Try reconnecting from the Source Control settings page.',
);
}