Properly report panic by resuming unwind
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use luajit::Chunk;
|
||||
use owo_colors::OwoColorize;
|
||||
use std::{
|
||||
fs,
|
||||
fs, panic,
|
||||
process::{self, ExitCode},
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ fn main() -> ExitCode {
|
||||
rt.unhandled_error(error_cb).build().unwrap()
|
||||
};
|
||||
|
||||
let path = "tests/test.lua";
|
||||
let path = "tests/main.lua";
|
||||
let main = lua.spawn(async move |s| {
|
||||
if let Err(ref err) = s.load(Chunk::new(fs::read(path).unwrap()).path(path)) {
|
||||
s.report_error(err);
|
||||
@@ -30,7 +30,10 @@ fn main() -> ExitCode {
|
||||
|
||||
tokio.block_on(async move {
|
||||
lua.await;
|
||||
main.await.unwrap()
|
||||
match main.await {
|
||||
Ok(res) => res,
|
||||
Err(err) => panic::resume_unwind(err.into_panic()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user