rune icon indicating copy to clipboard operation
rune copied to clipboard

How to get Rune backtraces for native Results at runtime?

Open VorpalBlade opened this issue 1 year ago • 1 comments
trafficstars

When Rune's Vm::async_call returns a VmError you can get a nice backtrace using VmError::emit. However if you return custom Result<T, CustomError> from your native methods it doesn't seem there is a way to capture the Rune backtrace as far as I can tell?

I could consider sticking the backtrace in my custom error type if I knew how to capture it when returning from my native code for example.

This is either a request for a feature or request for improved documentation (the latter I would be willing to PR if you point me in the right direction).

VorpalBlade avatar Aug 18 '24 06:08 VorpalBlade

A backtrace for the current vm could be extracted (stack frames) with the caveats that:

  • It would require a dedicated instruction to extract. " It would not be able to peek through native functions, futures, and generators (vm execution stuff).
  • It would only provide rich diagnostics if debug info is available.

udoprog avatar Aug 18 '24 15:08 udoprog