Skip to content

Commit

Permalink
Use specific errors in language tag assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
brawaru committed Jul 10, 2024
1 parent f21b106 commit c18fa02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vintl-nuxt/src/options/language-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export function assertLanguageTagValid(
input: unknown,
): asserts input is LanguageTag {
if (typeof input !== 'string') {
throw new Error('Language tag must be a string')
throw new TypeError('Language tag must be a string')
}

try {
new Intl.Locale(input)
} catch {
throw new Error('Language tag must be a valid BCP 47 language tag')
throw new RangeError('Language tag must be a valid BCP 47 language tag')
}
}

0 comments on commit c18fa02

Please sign in to comment.