From b2dcc233c002d82cd2746f6e26b630324d09c1e7 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 24 Oct 2020 17:07:19 -0700 Subject: [PATCH] wezterm: improve error reporting in `imgcat` This just includes the filename in the error message if we're unable to read a file. --- wezterm/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wezterm/src/main.rs b/wezterm/src/main.rs index 329fa0a8e..957c63d8e 100644 --- a/wezterm/src/main.rs +++ b/wezterm/src/main.rs @@ -1,4 +1,4 @@ -use anyhow::anyhow; +use anyhow::{anyhow, Context}; use config::wezterm_version; use mux::activity::Activity; use mux::pane::PaneId; @@ -136,7 +136,8 @@ impl ImgCatCommand { fn run(&self) -> anyhow::Result<()> { let mut data = Vec::new(); if let Some(file_name) = self.file_name.as_ref() { - let mut f = std::fs::File::open(file_name)?; + let mut f = std::fs::File::open(file_name) + .with_context(|| anyhow!("reading image file: {:?}", file_name))?; f.read_to_end(&mut data)?; } else { let mut stdin = std::io::stdin();