Skip to content

Invalid locale / date causes fatal error #3

@khromov

Description

@khromov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions