From abef92a9b341209aeae8802d30fc8c1f971a43df Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Sun, 26 Mar 2023 11:44:07 +0200 Subject: log failures in the git integration (#6441) --- helix-vcs/src/lib.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'helix-vcs/src/lib.rs') diff --git a/helix-vcs/src/lib.rs b/helix-vcs/src/lib.rs index 6f5e40d0..4d3a3623 100644 --- a/helix-vcs/src/lib.rs +++ b/helix-vcs/src/lib.rs @@ -1,3 +1,4 @@ +use anyhow::{bail, Result}; use arc_swap::ArcSwap; use std::{path::Path, sync::Arc}; @@ -18,19 +19,19 @@ pub trait DiffProvider { /// if this provider is used. /// The data is returned as raw byte without any decoding or encoding performed /// to ensure all file encodings are handled correctly. - fn get_diff_base(&self, file: &Path) -> Option>; - fn get_current_head_name(&self, file: &Path) -> Option>>>; + fn get_diff_base(&self, file: &Path) -> Result>; + fn get_current_head_name(&self, file: &Path) -> Result>>>; } #[doc(hidden)] pub struct Dummy; impl DiffProvider for Dummy { - fn get_diff_base(&self, _file: &Path) -> Option> { - None + fn get_diff_base(&self, _file: &Path) -> Result> { + bail!("helix was compiled without git support") } - fn get_current_head_name(&self, _file: &Path) -> Option>>> { - None + fn get_current_head_name(&self, _file: &Path) -> Result>>> { + bail!("helix was compiled without git support") } } @@ -42,13 +43,27 @@ impl DiffProviderRegistry { pub fn get_diff_base(&self, file: &Path) -> Option> { self.providers .iter() - .find_map(|provider| provider.get_diff_base(file)) + .find_map(|provider| match provider.get_diff_base(file) { + Ok(res) => Some(res), + Err(err) => { + log::error!("{err:#?}"); + log::error!("failed to open diff base for {}", file.display()); + None + } + }) } pub fn get_current_head_name(&self, file: &Path) -> Option>>> { self.providers .iter() - .find_map(|provider| provider.get_current_head_name(file)) + .find_map(|provider| match provider.get_current_head_name(file) { + Ok(res) => Some(res), + Err(err) => { + log::error!("{err:#?}"); + log::error!("failed to obtain current head name for {}", file.display()); + None + } + }) } } -- cgit v1.2.3-70-g09d2