Skip to content

fix(vm): keep host exception text out of pcall results - #443

Open
adriencohen wants to merge 1 commit into
deviceio:mainfrom
adriencohen:fix/pcall-host-exception-text
Open

adriencohen wants to merge 1 commit into
deviceio:mainfrom
adriencohen:fix/pcall-host-exception-text

Conversation

@adriencohen

Copy link
Copy Markdown

pcall handed the script the message of any exception raised by host code, and those messages can quote host data (a MatchError prints the unmatched term).

What changes

The script now gets "error in host function" for host exceptions. Errors raised for the script (error(), VM errors, Lua.API.runtime_exception!/1, {:error, reason}) pass through unchanged, and an uncaught host exception still reaches the host on :original.

Base functions that crashed with an Elixir exception on a bad argument now raise Lua errors, so their messages still reach the script.

os.time with an out-of-range field is left to #424.

pcall hands the script the text of host failures: the message of any
Elixir exception raised in host code (a MatchError message contains host
data), and the inspected return value of a Lua.set!/3 function that
returns unencoded data. The script now gets "error in host function" for
both.

Base-library functions that crashed with an Elixir exception on a bad
argument (rawget, rawset, os.date, ...) now raise Lua errors, so pcall
still reports them to the script.
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.

1 participant