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:
@@ -3,7 +3,7 @@ import { readFileSync, rmSync } from 'fs';
|
||||
import { InstanceSettings } from 'n8n-core';
|
||||
import type { ObjectLiteral } from 'typeorm';
|
||||
import type { QueryRunner } from 'typeorm/query-runner/QueryRunner';
|
||||
import { jsonParse } from 'n8n-workflow';
|
||||
import { ApplicationError, jsonParse } from 'n8n-workflow';
|
||||
import config from '@/config';
|
||||
import { inTest } from '@/constants';
|
||||
import type { BaseMigration, Migration, MigrationContext, MigrationFn } from '@db/types';
|
||||
@@ -23,7 +23,7 @@ function loadSurveyFromDisk(): string | null {
|
||||
const personalizationSurvey = JSON.parse(surveyFile) as object;
|
||||
const kvPairs = Object.entries(personalizationSurvey);
|
||||
if (!kvPairs.length) {
|
||||
throw new Error('personalizationSurvey is empty');
|
||||
throw new ApplicationError('personalizationSurvey is empty');
|
||||
} else {
|
||||
const emptyKeys = kvPairs.reduce((acc, [, value]) => {
|
||||
if (!value || (Array.isArray(value) && !value.length)) {
|
||||
@@ -32,7 +32,7 @@ function loadSurveyFromDisk(): string | null {
|
||||
return acc;
|
||||
}, 0);
|
||||
if (emptyKeys === kvPairs.length) {
|
||||
throw new Error('incomplete personalizationSurvey');
|
||||
throw new ApplicationError('incomplete personalizationSurvey');
|
||||
}
|
||||
}
|
||||
return surveyFile;
|
||||
@@ -68,7 +68,8 @@ const runDisablingForeignKeys = async (
|
||||
fn: MigrationFn,
|
||||
) => {
|
||||
const { dbType, queryRunner } = context;
|
||||
if (dbType !== 'sqlite') throw new Error('Disabling transactions only available in sqlite');
|
||||
if (dbType !== 'sqlite')
|
||||
throw new ApplicationError('Disabling transactions only available in sqlite');
|
||||
await queryRunner.query('PRAGMA foreign_keys=OFF');
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user