Skip to content

fix(loaders): return throwable on raised errors in rb_loader and lua_loader and test conversion - #952

Merged
viferga merged 4 commits into
metacall:developfrom
anmoltrivedi2312-ux:develop
Nov 12, 2026
Merged

viferga merged 4 commits into
metacall:developfrom
anmoltrivedi2312-ux:develop

Conversation

@anmoltrivedi2312-ux

@anmoltrivedi2312-ux anmoltrivedi2312-ux commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This ensures runtime exceptions are handled consistently between loaders. Any function which throws an error will return METACALL_THROWABLE rather than NULL. The metacall_conversion_test now also checks for throwables.

Changes

py_loader (py_loader_impl.c)

  • Renamed py_loader_impl_error_value and py_loader_impl_error_value_from_exception functions to py_loader_impl_throwable_value and py_loader_impl_exception_value respectively. This aligns with the underlying MetaCall type names TYPE_THROWABLE and TYPE_EXCEPTION.

rb_loader (rb_loader_impl.c)

  • Extracted rb_eException deserialization from rb_type_deserialize function to rb_loader_impl_exception_value(VALUE v). This includes all backtraces (joined by \n), errno extraction, and StringValueCStr.
  • Replaced rb_loader_impl_print_last_exception function with rb_loader_impl_throwable_value(void). This function takes rb_errinfo(), sets $! to nil (rb_set_errinfo(Qnil)), and wraps the exception in a throwable. All 4 paths calling rb_protect have been updated accordingly (fix(rb_loader): return TYPE_THROWABLE from invoke path on Ruby exception #689).

lua_loader (lua_loader_impl.c, metacall_lua_mixed_test.cpp)

  • Added lua_loader_impl_exception_value and lua_loader_impl_throwable_value functions. These will return METACALL_THROWABLE if status != 0 from lua_pcall.
  • Updated runtime_error_propagation and runtime_error_with_nil_access functions in metacall_lua_mixed_test.cpp to check for METACALL_THROWABLE.

metacall_conversion_test (metacall_conversion_test.cpp)

  • The throwable_ functions have been added for node, py, rb, and lua. These functions are checked to ensure they return METACALL_THROWABLE.
  • Added call to metacall::metacall_destroy() at the end of test. This ensures that reflect memory tracker counts are balanced.

@viferga
viferga merged commit 08022cb into metacall:develop Nov 12, 2026
105 of 148 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants