Commit df1f45c
fix(rb_loader): return TYPE_THROWABLE from invoke path on Ruby exception
When a Ruby function raises an exception, rb_protect() returns a non-zero
state but the invoke path fell through to rb_type_deserialize() on Qnil,
silently returning a TYPE_NULL value to the caller. The four TODO comments
marking this were unfixed since the issue was opened.
Replace the rb_loader_impl_print_last_exception macro (which only logged)
with a static helper rb_loader_impl_exception_value() that extracts the
pending exception from rb_errinfo(), builds a TYPE_THROWABLE value using
exception_create_const/throwable_create/value_create_throwable — the same
pattern used by py_loader_impl_error_value_from_exception() — and returns
it immediately. The error is cleared with rb_set_errinfo(Qnil) so it does
not propagate further up the Ruby stack.
All four invoke branches (TYPED, DUCKTYPED, MIXED, zero-args) now return a
structured throwable carrying the exception class name, message, and first
backtrace line. Node.js callers receive a native JS Error via the existing
TYPE_THROWABLE handling in node_loader_impl_value_to_napi(), and C callers
can extract the exception with metacall_error_from_value().
Fixes #141
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 44c62f9 commit df1f45c
1 file changed
Lines changed: 30 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
364 | 374 | | |
365 | 375 | | |
366 | 376 | | |
| |||
446 | 456 | | |
447 | 457 | | |
448 | 458 | | |
449 | | - | |
450 | | - | |
451 | | - | |
| 459 | + | |
452 | 460 | | |
453 | 461 | | |
454 | 462 | | |
| |||
465 | 473 | | |
466 | 474 | | |
467 | 475 | | |
468 | | - | |
469 | | - | |
470 | | - | |
| 476 | + | |
471 | 477 | | |
472 | 478 | | |
473 | 479 | | |
| |||
486 | 492 | | |
487 | 493 | | |
488 | 494 | | |
489 | | - | |
490 | | - | |
491 | | - | |
| 495 | + | |
492 | 496 | | |
493 | 497 | | |
494 | 498 | | |
| |||
506 | 510 | | |
507 | 511 | | |
508 | 512 | | |
509 | | - | |
510 | | - | |
511 | | - | |
| 513 | + | |
512 | 514 | | |
513 | 515 | | |
514 | 516 | | |
| |||
0 commit comments