MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / init_panic_handler

Function init_panic_handler

fendermint/app/src/main.rs:11–33  ·  view source on GitHub ↗

Install a panic handler that prints stuff to the logs, otherwise it only shows up in the console.

()

Source from the content-addressed store, hash-verified

9
10/// Install a panic handler that prints stuff to the logs, otherwise it only shows up in the console.
11fn init_panic_handler() {
12 let default_hook = std::panic::take_hook();
13
14 std::panic::set_hook(Box::new(move |info| {
15 // Do the default first, just in case logging fails too.
16 default_hook(info);
17
18 // let stacktrace = std::backtrace::Backtrace::capture();
19 let stacktrace = std::backtrace::Backtrace::force_capture();
20
21 subscriber::with_default(create_temporary_subscriber(), || {
22 tracing::error!(
23 stacktrace = stacktrace.to_string(),
24 info = info.to_string(),
25 "panicking"
26 );
27 });
28
29 // We could exit the application if any of the background tokio tasks panic.
30 // However, they are not necessarily critical processes, the chain might still make progress.
31 // std::process::abort();
32 }))
33}
34
35#[tokio::main]
36async fn main() {

Callers 1

mainFunction · 0.85

Calls 1

Tested by

no test coverage detected