Skip to content

Rendering errors always render the root +error.svelte, as opposed to the nearest error boundary #14410

@gaborluk

Description

@gaborluk

Describe the problem

In load functions, if an error occurs, the nearest +error.svelte is rendered.

In components, however, if an error occurs, the root +error.svelte is rendered.

I find this behavior unintuitive and disabling in designing the user experience, having the root business concern "leak" into a specialized subconcern of an app.

Describe the proposed solution

I assume there is no reason why the nearest +error.svelte could and should not be rendered – the route is known, and therefore the nearest error boundary is known as well.

If an error in the load function of a layout or page will render the nearest error boundary, one in the layout or page component ought to as well.

Alternatives considered

A workaround in #7875 (comment) is available for 404 errors, but not applicable to other errors.

Importance

i cannot use SvelteKit without it

Additional Information

In lieu of a fix for this behavior, is there a recommended way of rendering the nearest error boundary on rendering errors?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions