File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
packages/npm-packages/ruby-wasm-wasi/src Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -137,8 +137,7 @@ export class RubyVM {
137137 const str = new TextDecoder ( ) . decode (
138138 new Uint8Array ( memory . buffer , messagePtr , messageLen ) ,
139139 ) ;
140- throw new RbFatalError (
141- "Ruby APIs that may rewind the VM stack are prohibited under nested VM operation " +
140+ let message = "Ruby APIs that may rewind the VM stack are prohibited under nested VM operation " +
142141 `(${ str } )\n` +
143142 "Nested VM operation means that the call stack has sandwitched JS frames like JS -> Ruby -> JS -> Ruby " +
144143 "caused by something like `window.rubyVM.eval(\"JS.global[:rubyVM].eval('Fiber.yield')\")`\n" +
@@ -148,8 +147,13 @@ export class RubyVM {
148147 " Note that `evalAsync` JS API switches fibers internally\n" +
149148 " 2. Raising uncaught exceptions\n" +
150149 " Please catch all exceptions inside the nested operation\n" +
151- " 3. Calling Continuation APIs\n" ,
152- ) ;
150+ " 3. Calling Continuation APIs\n" ;
151+
152+ const error = new RbValue ( this . guest . rbErrinfo ( ) , this , this . privateObject ( ) ) ;
153+ if ( error . call ( "nil?" ) . toString ( ) === "false" ) {
154+ message += "\n" + this . exceptionFormatter . format ( error , this , this . privateObject ( ) ) ;
155+ }
156+ throw new RbFatalError ( message ) ;
153157 } ,
154158 } ;
155159 // NOTE: The GC may collect objects that are still referenced by Wasm
You can’t perform that action at this time.
0 commit comments