enso-org / enso

Hybrid visual and textual functional programming.
https://enso.org
Apache License 2.0
7.33k stars 320 forks source link

It is impossible to catch Panics in the GUI #9402

Open radeusgd opened 4 months ago

radeusgd commented 4 months ago

image

I would like to be able to catch a panic for example in order to inspect its stack trace.

Ideally, the visualization should allow to show a stack trace for a panic by default, but that's probably another thing.

Expected behaviour

The same operations in the REPL work and allow to catch a Panic:

Uncaught panic

> r = Panic.throw "foo"
null:: warning: Unused variable r.
Evaluation failed with: foo
java.lang.Exception: foo
        at <enso>.Panic.throw(Unknown Source)
        at <enso>.<eval>(Unknown Source)
        at <enso>.Debug.breakpoint(Unknown Source)
        at <enso>.Rrepl::Rrepl::main(Rrepl.enso:46)
        at <unknown>.org.graalvm.polyglot.Value<Function>.execute(Unknown Source)

> r
null:: error: The name `r` could not be found.
Evaluation failed with: Compilation aborted due to errors.
java.lang.Exception: Compilation aborted due to errors.
        at <enso>.Debug.breakpoint(Unknown Source)
        at <enso>.Rrepl::Rrepl::main(Rrepl.enso:46)
        at <unknown>.org.graalvm.polyglot.Value<Function>.execute(Unknown Source)

Panic recovered as dataflow error

> r = Panic.recover Any (Panic.throw "foo")
null:: warning: Unused variable r.
>>> Nothing
> r
>>> (Error: 'foo')
> r.catch
>>> foo

Caught panic

> r = Panic.catch Any (Panic.throw "foo") c->c.payload
null:: warning: Unused variable r.
>>> Nothing
> r
>>> foo
radeusgd commented 4 months ago

Added a triage label because while the issue is showing up in the GUI, it likely may be an issue in the runtime.