From ac3cee3fc6d4125994261fe4874bb2c4db8bb66f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 23 Dec 2021 15:04:19 -0700 Subject: [PATCH] kitty: improve debug when image id is not found Poking around at an issue, and thinking that some more context might be nice. Haven't managed to reproduce the issue so far though :-/ refs: https://github.com/wez/wezterm/issues/1156 --- term/src/terminalstate/kitty.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/term/src/terminalstate/kitty.rs b/term/src/terminalstate/kitty.rs index e83567fb8..b0116adbb 100644 --- a/term/src/terminalstate/kitty.rs +++ b/term/src/terminalstate/kitty.rs @@ -83,7 +83,12 @@ impl TerminalState { &image_number .ok_or_else(|| anyhow::anyhow!("no image_id or image_number specified!"))?, ) - .ok_or_else(|| anyhow::anyhow!("image_number has no matching image id"))?, + .ok_or_else(|| { + anyhow::anyhow!( + "image_number has no matching image id {:?} in number_to_id", + image_number + ) + })?, }; log::trace!( @@ -94,12 +99,13 @@ impl TerminalState { verbosity ); self.kitty_remove_placement(image_id, placement.placement_id); - let img = Arc::clone( - self.kitty_img - .id_to_data - .get(&image_id) - .ok_or_else(|| anyhow::anyhow!("no matching image id"))?, - ); + let img = Arc::clone(self.kitty_img.id_to_data.get(&image_id).ok_or_else(|| { + anyhow::anyhow!( + "no matching image id {} in id_to_data for image_number {:?}", + image_id, + image_number + ) + })?); let (image_width, image_height) = match &*img.data() { ImageDataType::EncodedFile(data) => { @@ -580,7 +586,11 @@ impl TerminalState { image_number, "ENOENT".to_string(), ); - anyhow::bail!("no matching image id") + anyhow::bail!( + "no matching image id {} in id_to_data for image_number {:?}", + image_id, + image_number + ) } };