Hi!
I was trying to add to vm a static function staticJustRaise, which is implemented in nim side and it would possibly raise several exceptions which are supposed to be handle by user code, similar to the existing stdlib.staticos.static* ones.
But I found something confusing: that the exceptions won't propagate to the user side, and the stacktrace only has only one frame.
vmops modifications:
# ...
proc callfurtherfurther() =
raise newException(ValueError, "by JustRaise") # line 161
proc callfurther() =
callfurtherfurther()
proc staticJustRaiseImpl(): bool =
callfurther()
return false
# ...
proc registerAdditionalOps*(c: PCtx) =
# ...
registerCallback c, "stdlib.staticos.staticJustRaise", proc (a: VmArgs) {.nimcall.} =
setResult(a, staticJustRaiseImpl())
# ...
User program:
import std/[staticos]
staticJustRaise()
The output is:
vmops.nim(161) callfurtherfurther
Error: unhandled exception: by JustRaise [ValueError]
And also surrounding staticJustRaise() by try ... except seems like a noop, where user are just not able to handle the exception thrown in this way.
I was wondering this is by design or missing some supports for exception propagation in vm?