Skip to content

Debugging Luau scripts runtime errors #317

Answered by khvzak
jqnatividad asked this question in Q&A
Discussion options

You must be logged in to vote

Do you have a script example please?

I tried to execute the following Lua file:

function throw_error()
    error("blah")
end

throw_error()

using optimized compiler:

    let compiler = mlua::Compiler::new()
        .set_optimization_level(2)
        .set_debug_level(1)
        .set_coverage_level(0);
    lua.set_compiler(compiler);
    let err = lua.load(Path::new("file.lua")).exec().err().unwrap();
    println!("{err}");

and got error:

runtime error: file.lua:2: blah
stack traceback:
        [C]: in ?
        [C]: in function 'error'
        file.lua:2: in function 'throw_error'
        file.lua:5: in ?

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by jqnatividad
Comment options

You must be logged in to vote
3 replies
@jqnatividad
Comment options

@khvzak
Comment options

@jqnatividad
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants