From 9f43f0c39f1e68446f0c52e502c16e9857a5af6e Mon Sep 17 00:00:00 2001 From: seditionist <84986004+seditionist@users.noreply.github.com> Date: Thu, 17 Aug 2023 00:12:27 -0400 Subject: [PATCH] update validRSN to use InvalidRSNError --- src/utils/helpers.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index ae9daeb..f3ba11a 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -7,7 +7,8 @@ import { SCORES_URL, SKILLS, ACTIVITIES, - JSON_STATS_URL + JSON_STATS_URL, + InvalidRSNError } from './constants'; /** @@ -119,10 +120,10 @@ export const httpGet = ( */ export const validateRSN = (rsn: string) => { if (typeof rsn !== 'string') { - throw Error('RSN must be a string'); + throw new InvalidRSNError('RSN must be a string'); } else if (!/^[a-zA-Z0-9 _-]+$/.test(rsn)) { - throw Error('RSN contains invalid character'); + throw new InvalidRSNError('RSN contains invalid character'); } else if (rsn.length > 12 || rsn.length < 1) { - throw Error('RSN must be between 1 and 12 characters'); + throw new InvalidRSNError('RSN must be between 1 and 12 characters'); } };