tomaka / hlua

Rust library to interface with Lua
MIT License
507 stars 48 forks source link

Examples for error handling #184

Open kpcyrd opened 6 years ago

kpcyrd commented 6 years ago

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:

Help would be appreciated!