Skip to content

No way to catch exceptions in reactive statements #6936

@BartVanBeurden

Description

@BartVanBeurden

Describe the bug

When a reactive statement throws an error, there is no mechanism to catch it.

  1. You cannot try/catch the reactive statement ($: has no effect outside of the top-level)
  2. window.onerror does not catch it
  3. window.onunhandledrejection does not catch it

The best you can do is try/catch inside a function that is reactively called, but my goal is to have a global exception handler to handle all exceptions that I did not expect...

Reproduction

https://svelte.dev/repl/d3a8223398e5414a9b19d63bf1b46a34?version=3.44.1

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 30.93 GB / 63.90 GB
  Binaries:
    Node: 16.3.0 - C:\Program Files\nodejs\node.EXE
    npm: 7.22.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (95.0.1020.53)     
  npmPackages:
    rollup: ^2.56.3 => 2.59.0
    svelte: ^3.42.4 => 3.44.1

Severity

annoyance

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