Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: register panic handler
✗ CI failure Fintan Halpenny committed 10 months ago
commit ddf9231a63bc4dd53a80ed96c02838ecbea206a0
parent a266e315aabc035c1f2f499a52f37c73037e0bf8
1 failed (1 total) View logs
1 file changed +23 -0
modified crates/radicle-node/src/main.rs
@@ -138,6 +138,7 @@ fn main() {
    if std::env::var_os(RUST_BACKTRACE).is_none() {
        std::env::set_var(RUST_BACKTRACE, "1");
    }
+
    panic_handler();

    if let Err(err) = execute() {
        if log::log_enabled!(target: "node", log::Level::Error) {
@@ -148,3 +149,25 @@ fn main() {
        process::exit(1);
    }
}
+

+
/// Custom panic handler.
+
///
+
/// It captures the current panic hook, prints the custom error message, and
+
/// resumes the captured panic handler.
+
fn panic_handler() {
+
    let prev = std::panic::take_hook();
+
    std::panic::set_hook(Box::new(move |info| {
+
        let err = r#"
+
radicle-node: fatal error
+

+
👾 Something went wrong!
+

+
This is almost certainly a bug, and we'd appreciate a report so we can improve Radicle.
+

+
Please report this error with `rad issue open --repo rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5`,
+
or on https://radicle.zulipchat.com/#narrow/channel/369873-support.
+
"#;
+
        eprintln!("\n{err}");
+
        prev(info);
+
    }));
+
}