forked from argotorg/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanic.rs
More file actions
24 lines (21 loc) · 836 Bytes
/
Copy pathpanic.rs
File metadata and controls
24 lines (21 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use once_cell::sync::Lazy;
use std::panic;
const BUG_REPORT_URL: &str = "https://github.com/ethereum/fe/issues/new";
type PanicCallback = dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static;
static DEFAULT_PANIC_HOOK: Lazy<Box<PanicCallback>> = Lazy::new(|| {
let hook = panic::take_hook();
panic::set_hook(Box::new(report_ice));
hook
});
pub fn install_panic_hook() {
Lazy::force(&DEFAULT_PANIC_HOOK);
}
fn report_ice(info: &panic::PanicInfo) {
(*DEFAULT_PANIC_HOOK)(info);
eprintln!();
eprintln!("You've hit an internal compiler error. This is a bug in the Fe compiler.");
eprintln!("Fe is still under heavy development, and isn't yet ready for production use.");
eprintln!();
eprintln!("If you would, please report this bug at the following URL:");
eprintln!(" {BUG_REPORT_URL}");
}