From 3f6c6dc4d478ded48ef4aef638546964628320e9 Mon Sep 17 00:00:00 2001 From: David <35281350+Drylozu@users.noreply.github.com> Date: Fri, 13 Jun 2025 00:11:56 -0500 Subject: [PATCH] fix: add error handling for undefined locale (#344) --- src/langs/router.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/langs/router.ts b/src/langs/router.ts index b255792..0e3ed2c 100644 --- a/src/langs/router.ts +++ b/src/langs/router.ts @@ -14,6 +14,7 @@ export const LangRouter = (userLocale: string, defaultLang: string, langs: Parti function getValue(locale?: string) { if (typeof locale === 'undefined') throw new Error('Undefined locale'); let value = langs[locale] as Record; + if (typeof value === 'undefined') throw new Error(`Locale "${locale}" not found`); for (const i of route) value = value[i]; return value; } @@ -51,4 +52,4 @@ export type __InternalParseLocale> = { }; export type ParseLocales> = T; -/**Idea inspiration from: FreeAoi */ +/**Idea inspiration from: FreeAoi | Fixed by: Drylozu */