From b3093b23e3e89ae10755068bd29032fdd3f1cad8 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Thu, 13 Jul 2023 00:06:01 -0600 Subject: [PATCH] fix: avoid displaying `null` in alerts --- backend/UserConfig.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/UserConfig.ts b/backend/UserConfig.ts index 36b59ce..63d27b4 100644 --- a/backend/UserConfig.ts +++ b/backend/UserConfig.ts @@ -44,12 +44,15 @@ export class UserConfig { } } + /** + * Ensures that all config options are valid + */ private parseConfig(config: UserConfiguration) { if (!Checkers.uploadsDir(config.uploadsDir)) throw new Error(`Unable to access uploads directory: ${config.uploadsDir}`); - if (!Checkers.idType(config.idType)) throw new Error(`Invalid ID type: ${config.idType}`); - if (!Checkers.idSize(config.idSize)) throw new Error(`Invalid ID size: ${config.idSize}`); - if (!Checkers.gfySize(config.gfySize)) throw new Error(`Invalid Gfy size: ${config.gfySize}`); - if (!Checkers.maximumFileSize(config.maximumFileSize)) throw new Error(`Invalid maximum file size: ${config.maximumFileSize}`); + if (!Checkers.idType(config.idType)) throw new Error('Invalid ID type'); + if (!Checkers.idSize(config.idSize)) throw new Error('Invalid ID size'); + if (!Checkers.gfySize(config.gfySize)) throw new Error('Invalid Gfy size'); + if (!Checkers.maximumFileSize(config.maximumFileSize)) throw new Error('Invalid maximum file size'); // All is fine, carry on! return config;