Skip to content

Commit

Permalink
Display captured backtrace when available
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus-consoli committed May 24, 2024
1 parent 96a45ee commit dfc7206
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion apps/desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ async fn main() -> tauri::Result<()> {

handle.windows().iter().for_each(|(_, window)| {
if should_clear_localstorage {
println!("bruh?");
for webview in window.webviews() {
webview.eval("localStorage.clear();").ok();
}
Expand Down
10 changes: 8 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ impl Node {
"info"
};

// let level = "debug"; // Exists for now to debug the location manager

std::env::set_var(
"RUST_LOG",
format!("info,sd_core={level},sd_p2p=debug,sd_core::location::manager=info,sd_ai={level}"),
Expand All @@ -239,12 +237,20 @@ impl Node {
.init();

std::panic::set_hook(Box::new(move |panic| {
use std::backtrace::{Backtrace, BacktraceStatus};
let backtrace = Backtrace::capture();
if let Some(location) = panic.location() {
tracing::error!(
message = %panic,
panic.file = format!("{}:{}", location.file(), location.line()),
panic.column = location.column(),
);
if backtrace.status() == BacktraceStatus::Captured {
// NOTE(matheus-consoli): it seems that `tauri` is messing up the stack-trace
// and it doesn't capture anything, even when `RUST_BACKTRACE=full`,
// so in the current architecture, this is emitting an empty event.
tracing::error!(message = %backtrace);
}
} else {
tracing::error!(message = %panic);
}
Expand Down

0 comments on commit dfc7206

Please sign in to comment.