File tree Expand file tree Collapse file tree
crates/amaru/src/bin/amaru Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515/// Installs a panic handler that prints some useful diagnostics and
1616/// asks the user to report the issue.
1717pub fn panic_handler ( ) {
18+ let prev = std:: panic:: take_hook ( ) ;
1819 std:: panic:: set_hook ( Box :: new ( move |info| {
19- let message = info
20- . payload ( )
21- . downcast_ref :: < & str > ( )
22- . map ( |s| ( * s) . to_string ( ) )
23- . or_else ( || {
24- info. payload ( )
25- . downcast_ref :: < String > ( )
26- . map ( |s| s. to_string ( ) )
27- } )
28- . unwrap_or_else ( || "unknown error" . to_string ( ) ) ;
29-
30- let location = info. location ( ) . map_or_else (
31- || "" . into ( ) ,
32- |location| {
33- format ! (
34- "{}:{}:{}\n \n " ,
35- location. file( ) ,
36- location. line( ) ,
37- location. column( ) ,
38- )
39- } ,
40- ) ;
41-
4220 // We present the user with a helpful and welcoming error message;
4321 // Block producing nodes should be considered mission critical software, and so
4422 // They should endeavor *never* to crash, and should always handle and recover from errors.
@@ -56,14 +34,13 @@ pub fn panic_handler() {
5634 In your bug report please provide the information below and if possible the code
5735 that produced it.
5836 {info}
59-
60- {location}{message} "# ,
37+
38+ "# ,
6139 info = node_info( ) ,
6240 fatal = "amaru::fatal::error" ,
63- location = location,
6441 } ;
65-
6642 eprintln ! ( "\n {}" , indent( & error_message, 3 ) ) ;
43+ prev ( info) ;
6744 } ) ) ;
6845}
6946
You can’t perform that action at this time.
0 commit comments