Files
Automata/packages/cli/src/config/utils.ts
Iván Ovejero c08c5cc37b 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
2023-11-29 12:25:10 +01:00

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);
}
};