From d530d6e39d58f5759d2db0a9bda1ea5e21154f83 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sun, 11 Jul 2021 16:35:57 +0900 Subject: Further simplify error handling in :commands --- helix-view/src/editor.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'helix-view') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index c80535ed..a468b87c 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -98,14 +98,11 @@ impl Editor { } pub fn set_theme_from_name(&mut self, theme: &str) -> anyhow::Result<()> { - let theme = match self.theme_loader.load(theme.as_ref()) { - Ok(theme) => theme, - Err(e) => { - log::warn!("failed setting theme `{}` - {}", theme, e); - anyhow::bail!("failed setting theme `{}` - {}", theme, e); - } - }; - + use anyhow::Context; + let theme = self + .theme_loader + .load(theme.as_ref()) + .with_context(|| format!("failed setting theme `{}`", theme))?; self.set_theme(theme); Ok(()) } -- cgit v1.2.3-70-g09d2