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:
@@ -1,7 +1,7 @@
|
||||
import convict from 'convict';
|
||||
import dotenv from 'dotenv';
|
||||
import { readFileSync } from 'fs';
|
||||
import { setGlobalState } from 'n8n-workflow';
|
||||
import { ApplicationError, setGlobalState } from 'n8n-workflow';
|
||||
import { inTest, inE2ETests } from '@/constants';
|
||||
|
||||
if (inE2ETests) {
|
||||
@@ -53,7 +53,7 @@ if (!inE2ETests && !inTest) {
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
if (error.code === 'ENOENT') {
|
||||
throw new Error(`The file "${fileName}" could not be found.`);
|
||||
throw new ApplicationError('File not found', { extra: { fileName } });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { NotStringArrayError } from '@/errors/not-string-array.error';
|
||||
import type { SchemaObj } from 'convict';
|
||||
import { ApplicationError } from 'n8n-workflow';
|
||||
|
||||
export const ensureStringArray = (values: string[], { env }: SchemaObj<string>) => {
|
||||
if (!env) throw new Error(`Missing env: ${env}`);
|
||||
if (!env) throw new ApplicationError('Missing env', { extra: { env } });
|
||||
|
||||
if (!Array.isArray(values)) throw new NotStringArrayError(env);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user