2023-01-19 01:47:14 +00:00
|
|
|
pub fn pretty_print_luau_error(e: &mlua::Error) {
|
|
|
|
match e {
|
|
|
|
mlua::Error::RuntimeError(e) => {
|
|
|
|
eprintln!("{}", e);
|
|
|
|
}
|
|
|
|
mlua::Error::CallbackError { cause, traceback } => {
|
|
|
|
pretty_print_luau_error(cause.as_ref());
|
|
|
|
eprintln!("Traceback:");
|
|
|
|
eprintln!("{}", traceback.strip_prefix("stack traceback:\n").unwrap());
|
|
|
|
}
|
|
|
|
mlua::Error::ToLuaConversionError { from, to, message } => {
|
|
|
|
let msg = message
|
|
|
|
.clone()
|
|
|
|
.map(|m| format!("\nDetails:\n\t{m}"))
|
|
|
|
.unwrap_or_else(|| "".to_string());
|
|
|
|
eprintln!(
|
|
|
|
"Failed to convert Rust type '{}' into Luau type '{}'!{}",
|
|
|
|
from, to, msg
|
|
|
|
)
|
|
|
|
}
|
|
|
|
mlua::Error::FromLuaConversionError { from, to, message } => {
|
|
|
|
let msg = message
|
|
|
|
.clone()
|
|
|
|
.map(|m| format!("\nDetails:\n\t{m}"))
|
|
|
|
.unwrap_or_else(|| "".to_string());
|
|
|
|
eprintln!(
|
|
|
|
"Failed to convert Luau type '{}' into Rust type '{}'!{}",
|
|
|
|
from, to, msg
|
|
|
|
)
|
|
|
|
}
|
2023-01-19 02:11:47 +00:00
|
|
|
e => eprintln!("{e}"),
|
2023-01-19 01:47:14 +00:00
|
|
|
}
|
|
|
|
}
|