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"
|
release.panic = "abort"
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "test"
|
name = "main"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
@ -44,7 +44,7 @@ tokio-console = ["dep:console-subscriber"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.40", features = ["derive", "env"] }
|
clap = { version = "4.5.40", features = ["derive", "env"] }
|
||||||
console-subscriber = { version = "0.4.1", optional = true }
|
console-subscriber = { version = "0.4.1", optional = true }
|
||||||
lb = { path = "crates/lb" }
|
lb = { path = "crates/lb", features = ["runtime"] }
|
||||||
luajit = { path = "crates/luajit", features = ["runtime"] }
|
luajit = { path = "crates/luajit", features = ["runtime"] }
|
||||||
mimalloc = "0.1.47"
|
mimalloc = "0.1.47"
|
||||||
owo-colors = "4.2.1"
|
owo-colors = "4.2.1"
|
||||||
|
@ -8,6 +8,7 @@ homepage.workspace = true
|
|||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
runtime = ["tokio/rt"]
|
||||||
task = ["tokio/rt", "tokio/time"]
|
task = ["tokio/rt", "tokio/time"]
|
||||||
fs = ["tokio/fs", "dep:walkdir", "dep:globset", "dep:tempfile"]
|
fs = ["tokio/fs", "dep:walkdir", "dep:globset", "dep:tempfile"]
|
||||||
net = ["tokio/net"]
|
net = ["tokio/net"]
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
//! luby standard library
|
//! luby standard library
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
pub mod runtime;
|
|
||||||
|
|
||||||
#[cfg(feature = "task")]
|
#[cfg(feature = "task")]
|
||||||
pub mod chan;
|
pub mod chan;
|
||||||
#[cfg(feature = "fs")]
|
#[cfg(feature = "fs")]
|
||||||
pub mod fs;
|
pub mod fs;
|
||||||
#[cfg(feature = "net")]
|
#[cfg(feature = "net")]
|
||||||
pub mod net;
|
pub mod net;
|
||||||
|
#[cfg(feature = "runtime")]
|
||||||
|
pub mod runtime;
|
||||||
#[cfg(feature = "task")]
|
#[cfg(feature = "task")]
|
||||||
pub mod task;
|
pub mod task;
|
||||||
|
@ -153,7 +153,10 @@ fn main() -> Result<(), ExitCode> {
|
|||||||
|
|
||||||
tokio.block_on(async {
|
tokio.block_on(async {
|
||||||
lua.await;
|
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 luajit::Chunk;
|
||||||
use owo_colors::OwoColorize;
|
use owo_colors::OwoColorize;
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs, panic,
|
||||||
process::{self, ExitCode},
|
process::{self, ExitCode},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ fn main() -> ExitCode {
|
|||||||
rt.unhandled_error(error_cb).build().unwrap()
|
rt.unhandled_error(error_cb).build().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = "tests/test.lua";
|
let path = "tests/main.lua";
|
||||||
let main = lua.spawn(async move |s| {
|
let main = lua.spawn(async move |s| {
|
||||||
if let Err(ref err) = s.load(Chunk::new(fs::read(path).unwrap()).path(path)) {
|
if let Err(ref err) = s.load(Chunk::new(fs::read(path).unwrap()).path(path)) {
|
||||||
s.report_error(err);
|
s.report_error(err);
|
||||||
@ -30,7 +30,10 @@ fn main() -> ExitCode {
|
|||||||
|
|
||||||
tokio.block_on(async move {
|
tokio.block_on(async move {
|
||||||
lua.await;
|
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