Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples for error handling #184

Open
kpcyrd opened this issue Mar 17, 2018 · 0 comments
Open

Examples for error handling #184

kpcyrd opened this issue Mar 17, 2018 · 0 comments

Comments

@kpcyrd
Copy link
Contributor

kpcyrd commented Mar 17, 2018

I'm trying to add error handling to my code, sadly I'm having trouble getting it to work:

If your Rust function returns a Result object which contains an error, then a Lua error will be triggered.

My setup looks like this:
rust runtime -> calls into a lua script -> calls into a rust function I'm providing
the error happens inside the rust function that I'm calling. The script looks like this:

function verify(user, password)
    return execve("./2docs/test.sh", {user, password}) == 0
end

where ./2docs doesn't exist and causes an Err(_), but the result of .call_with_args is Ok(LuaBoolean(false)). When removing the == 0 I'm getting LuaNil which doesn't seem like an error either.

What I'm trying to do:

  • either get an error inside the lua script that I can return to the runtime
  • do something inside the rust function that allows my to abort the script and return the error directly to the runtime

Help would be appreciated!

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

No branches or pull requests

1 participant