From 428fa7a8d208771e73fa07ef494fe46bf20c5d1d Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Wed, 9 Oct 2024 08:42:04 +0200 Subject: [PATCH] refactor(errors): improve message and add logging when sending tree from backend panics (#314) Related #239 Related #209 --------- Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- crates/core/src/blob/tree.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/core/src/blob/tree.rs b/crates/core/src/blob/tree.rs index ffd03577..1511d47c 100644 --- a/crates/core/src/blob/tree.rs +++ b/crates/core/src/blob/tree.rs @@ -13,6 +13,7 @@ use derive_setters::Setters; use ignore::overrides::{Override, OverrideBuilder}; use ignore::Match; +use log::debug; use serde::{Deserialize, Deserializer}; use serde_derive::Serialize; @@ -689,9 +690,17 @@ impl TreeStreamerOnce

{ let out_tx = out_tx.clone(); let _join_handle = std::thread::spawn(move || { for (path, id, count) in in_rx { - out_tx - .send(Tree::from_backend(&be, &index, id).map(|tree| (path, tree, count))) - .unwrap(); + debug!("Loading tree {id} from {path:?} with count {count}"); + + if let Err(err) = out_tx.try_send( + Tree::from_backend(&be, &index, id).map(|tree| (path, tree, count)), + ) { + panic!(" + Sending tree {id} on channel failed: {err}. + + This should not happen! Please report it to the developers: https://github.com/rustic-rs/rustic_core/issues/new + "); + } } }); }