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
14 lines
495 B
TypeScript
14 lines
495 B
TypeScript
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 ApplicationError('Missing env', { extra: { env } });
|
|
|
|
if (!Array.isArray(values)) throw new NotStringArrayError(env);
|
|
|
|
for (const value of values) {
|
|
if (typeof value !== 'string') throw new NotStringArrayError(env);
|
|
}
|
|
};
|