Skip to content

{#await} blocks without {:catch} should also trigger <svelte:boundary> #15803

Open
@WaltzingPenguin

Description

@WaltzingPenguin

Describe the problem

I have a <svelte:boundary> in my code for catching some potential issues. Inside of that is an {#await} that, since it hits the network, always has a chance to fail. I would like the display and handling of these two error conditions to be the same, but there's no good way to trigger the boundary when a promise fails.

Describe the proposed solution

I would like svelte:boundary to also catch errors in promises. Currently, this just renders blank:

<svelte:boundary>
  {#await Promise.reject()}
    Loading...
  {:then _}
     Loaded
   {/await}

  {#snippet failed()}
    An error has occurred
  {/snippet}
</svelte:boundary>

If there is a {:catch} on the block, that should not propagate up the boundary.

<svelte:boundary>
  {#await Promise.reject() then _}
    Loading...
  {:then _}
     Loaded
  {:catch}
     This error should be displayed
   {/await}

  {#snippet failed()}
    This error should not be shown
  {/snippet}
</svelte:boundary>

Importance

would make my life easier

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