@@ -11,6 +11,7 @@ use lsp_types::{
11
11
Url ,
12
12
} ;
13
13
use nix_interop:: { flake_lock, FLAKE_FILE , FLAKE_LOCK_FILE } ;
14
+ use std:: backtrace:: Backtrace ;
14
15
use std:: cell:: Cell ;
15
16
use std:: collections:: HashMap ;
16
17
use std:: io:: ErrorKind ;
@@ -666,11 +667,14 @@ fn with_catch_unwind<T>(ctx: &str, f: impl FnOnce() -> Result<T> + UnwindSafe) -
666
667
INSTALL_PANIC_HOOK . call_once ( || {
667
668
let old_hook = panic:: take_hook ( ) ;
668
669
panic:: set_hook ( Box :: new ( move |info| {
669
- if let Some ( loc) = info. location ( ) {
670
- PANIC_LOCATION . with ( |inner| {
671
- inner. set ( loc. to_string ( ) ) ;
672
- } ) ;
673
- }
670
+ let loc = info
671
+ . location ( )
672
+ . map ( |loc| loc. to_string ( ) )
673
+ . unwrap_or_default ( ) ;
674
+ let backtrace = Backtrace :: force_capture ( ) ;
675
+ PANIC_LOCATION . with ( |inner| {
676
+ inner. set ( format ! ( "Location: {loc:#}\n Backtrace: {backtrace:#}" ) ) ;
677
+ } ) ;
674
678
old_hook ( info) ;
675
679
} ) )
676
680
} ) ;
@@ -685,9 +689,10 @@ fn with_catch_unwind<T>(ctx: &str, f: impl FnOnce() -> Result<T> + UnwindSafe) -
685
689
. unwrap_or ( "unknown" ) ;
686
690
let mut loc = PANIC_LOCATION . with ( |inner| inner. take ( ) ) ;
687
691
if loc. is_empty ( ) {
688
- loc = "unknown" . into ( ) ;
692
+ loc = "Location: unknown" . into ( ) ;
689
693
}
690
- bail ! ( "Panicked in {ctx} at {loc}: {reason}" ) ;
694
+ tracing:: error!( "Panicked in {ctx}: {reason}\n {loc}" ) ;
695
+ bail ! ( "Panicked in {ctx}: {reason}\n {loc}" ) ;
691
696
}
692
697
}
693
698
}
0 commit comments