mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 07:07:07 +03:00
added custom panic hook (#1762)
This commit is contained in:
parent
23fca6af47
commit
b767498152
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -1262,6 +1262,7 @@ version = "1.5.3"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"assert_cmd",
|
||||
"backtrace",
|
||||
"clap 3.1.9",
|
||||
"color-backtrace",
|
||||
"colored",
|
||||
@ -1282,6 +1283,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"snarkvm-utilities 0.7.5 (git+https://github.com/AleoHQ/snarkVM.git?rev=51633e2)",
|
||||
"structopt",
|
||||
"sys-info",
|
||||
"test_dir",
|
||||
"toml",
|
||||
"tracing",
|
||||
@ -2589,6 +2591,16 @@ dependencies = [
|
||||
"unicode-xid 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sys-info"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.3.0"
|
||||
|
@ -59,6 +59,12 @@ version = "0.5.1"
|
||||
[dependencies.colored]
|
||||
version = "2.0"
|
||||
|
||||
[dependencies.backtrace]
|
||||
version = "0.3.65"
|
||||
|
||||
[dependencies.sys-info]
|
||||
version = "0.9.1"
|
||||
|
||||
[dependencies.dirs]
|
||||
version = "4.0.0"
|
||||
|
||||
|
32
leo/main.rs
32
leo/main.rs
@ -175,8 +175,38 @@ enum CommandOpts {
|
||||
// },
|
||||
}
|
||||
|
||||
fn set_panic_hook() {
|
||||
#[cfg(not(debug_assertions))]
|
||||
std::panic::set_hook({
|
||||
Box::new(move |e| {
|
||||
println!(
|
||||
"thread `{}` {}",
|
||||
std::thread::current().name().unwrap_or("<unnamed>"),
|
||||
e
|
||||
);
|
||||
println!("stack backtrace: \n{:?}", backtrace::Backtrace::new());
|
||||
println!("error: internal compiler error: unexpected panic\n");
|
||||
println!("note: the compiler unexpectedly panicked. this is a bug.\n");
|
||||
println!("note: we would appreciate a bug report: https://github.com/AleoHQ/leo/issues/new?labels=bug,panic&template=bug.md&title=[Bug]\n");
|
||||
println!(
|
||||
"note: {} {} running on {} {}\n",
|
||||
env!("CARGO_PKG_NAME"),
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
sys_info::os_type().unwrap_or_else(|e| e.to_string()),
|
||||
sys_info::os_release().unwrap_or_else(|e| e.to_string()),
|
||||
);
|
||||
println!(
|
||||
"note: compiler args: {}\n",
|
||||
std::env::args().collect::<Vec<_>>().join(" ")
|
||||
);
|
||||
println!("note: compiler flags: {:?}\n", Opt::from_args());
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fn main() {
|
||||
handle_error(run_with_args(Opt::from_args()))
|
||||
set_panic_hook();
|
||||
handle_error(run_with_args(Opt::from_args()));
|
||||
}
|
||||
|
||||
/// Run command with custom build arguments.
|
||||
|
Loading…
Reference in New Issue
Block a user