Properly report panic by resuming unwind
This commit is contained in:
parent
5f1f6dab7a
commit
6a4c726965
@ -31,7 +31,7 @@ dev.panic = "abort"
|
||||
release.panic = "abort"
|
||||
|
||||
[[test]]
|
||||
name = "test"
|
||||
name = "main"
|
||||
harness = false
|
||||
|
||||
[features]
|
||||
@ -44,7 +44,7 @@ tokio-console = ["dep:console-subscriber"]
|
||||
[dependencies]
|
||||
clap = { version = "4.5.40", features = ["derive", "env"] }
|
||||
console-subscriber = { version = "0.4.1", optional = true }
|
||||
lb = { path = "crates/lb" }
|
||||
lb = { path = "crates/lb", features = ["runtime"] }
|
||||
luajit = { path = "crates/luajit", features = ["runtime"] }
|
||||
mimalloc = "0.1.47"
|
||||
owo-colors = "4.2.1"
|
||||
|
@ -8,6 +8,7 @@ homepage.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[features]
|
||||
runtime = ["tokio/rt"]
|
||||
task = ["tokio/rt", "tokio/time"]
|
||||
fs = ["tokio/fs", "dep:walkdir", "dep:globset", "dep:tempfile"]
|
||||
net = ["tokio/net"]
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! luby standard library
|
||||
#![warn(missing_docs)]
|
||||
pub mod runtime;
|
||||
|
||||
#[cfg(feature = "task")]
|
||||
pub mod chan;
|
||||
#[cfg(feature = "fs")]
|
||||
pub mod fs;
|
||||
#[cfg(feature = "net")]
|
||||
pub mod net;
|
||||
#[cfg(feature = "runtime")]
|
||||
pub mod runtime;
|
||||
#[cfg(feature = "task")]
|
||||
pub mod task;
|
||||
|
@ -153,7 +153,10 @@ fn main() -> Result<(), ExitCode> {
|
||||
|
||||
tokio.block_on(async {
|
||||
lua.await;
|
||||
main.await.unwrap()
|
||||
match main.await {
|
||||
Ok(res) => res,
|
||||
Err(err) => panic::resume_unwind(err.into_panic()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user