Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid locale / date causes fatal error #3

Open
khromov opened this issue Jul 15, 2023 · 0 comments
Open

Invalid locale / date causes fatal error #3

khromov opened this issue Jul 15, 2023 · 0 comments

Comments

@khromov
Copy link

khromov commented Jul 15, 2023

When specifying an invalid locale like locale: "test" the component crashes the whole page:

formatter.js:8 Uncaught (in promise) RangeError: Incorrect locale information provided
    at new RelativeTimeFormat (<anonymous>)
    at getFormatter (formatter.js:8:23)
    at register (state.js:10:23)
    at init2 (action.js:8:9)
    at relativeTime (action.js:10:5)
    at mount (Message.svelte:178:22)
    at targetCmp.$$.fragment.m (svelte-hooks.js?v=2364f85d:291:24)
    at mount_component (Component.js:44:23)
    at Object.mount [as m] (http://localhost:5173/src/routes/(app)/jar/+page.svelte:937:4)
    at Object.mount [as m] (http://localhost:5173/src/routes/(app)/jar/+page.svelte:691:21)

The same happens when an invalid date is specified.

Since Svelte has no support for error boundaries, it's very hard to catch these errors in component init. It would be better if this component handled it gracefully with try/catch (for example, printing a console.warn() about the issue) and not display anything if there was an error.

@khromov khromov changed the title Invalid locals / date causes fatal Invalid locale / date causes fatal error Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant