Maybe I'm doing something wrong but when I expose code from my main program to the scripts, via interpreter.implementRoutine, and the native code has an error, that error is eaten on the way and I just get a general script error from the call site inside the nimscript.
I can see why this would happen, but it makes debugging the code a bit of a problem since you basically have to recreate the same call in the main program and trigger the fault there to get the real error to surface.
Is there any way to dig the real error out from the VM metadata at runtime? I checked some of the data structures, the line info and config that is returned to the handler set by interpreter.registerErrorHook, but I didn't find anything that looked like what I would need for this there.
There is a mechanism called getError that is used for VM/native integration for os.nim:
proc getError: string = builtin
...
result.registerCallback "stdlib.system.getError",
proc (a: VmArgs) = setResult(a, errorMsg)
You could use the existing getError or a similar mechanism to communiate errors between the native and the VM code.