mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
chore: throw 'LuaError::RuntimeError' if first byte indicates an error
This commit is contained in:
parent
b4ff4a5b06
commit
b5906b2ec8
1 changed files with 9 additions and 1 deletions
|
@ -4,6 +4,7 @@ use mlua::Compiler as LuaCompiler;
|
|||
use crate::lune::lua::table::TableBuilder;
|
||||
|
||||
const DEFAULT_DEBUG_NAME: &str = "luau.load(...)";
|
||||
const BYTECODE_ERROR_BYTE: u8 = 0;
|
||||
|
||||
struct CompileOptions {
|
||||
pub optimization_level: u8,
|
||||
|
@ -114,7 +115,14 @@ fn compile_source<'lua>(
|
|||
.set_debug_level(_options.debug_level)
|
||||
.compile(source);
|
||||
|
||||
lua.create_string(source_bytecode_bytes)
|
||||
let first_byte = source_bytecode_bytes.first().unwrap();
|
||||
|
||||
match *first_byte {
|
||||
BYTECODE_ERROR_BYTE => Err(LuaError::RuntimeError(
|
||||
String::from_utf8(source_bytecode_bytes).unwrap(),
|
||||
)),
|
||||
_ => lua.create_string(source_bytecode_bytes),
|
||||
}
|
||||
}
|
||||
|
||||
fn load_source<'a>(
|
||||
|
|
Loading…
Add table
Reference in a new issue