Skip to content

[LiveComponent] Improve error handling or make it customizable #3388

@aleho

Description

@aleho

Currently errors in live components are handled in the live_controller.js by creating a modal and laying it over the page content.

This has a few issues in my opinion:

  1. The exception is rendered as the whole page, essentially leading to the error page being a "modal child" of the page that loaded a live component. That modal has very bad UX (it closes by clicking on the backdrop, for example).
  2. There's no way of configuring that behavior without completely overriding central parts of the live component implementation.
  3. Some errors are "hard" to handle, e.g., [LiveComponent] Cannot find a template, cache may be corrupt #2635, because they throw a generic \RuntimeException where you have to match the exception message and cannot rely on that not breaking.

In Twig components you could still handle exceptions yourself, but in live components you're depending on the upstream implementation. In my opinion live components could benefit from an improved and customizable error handling.

At the very least I propose to throw live component exceptions instead of generic ones as a first step to be able to catch them reliably. I can create a PR for that if that's OK with you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LiveComponentRFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions