From 52f0c8bb836c6d50b7ce2393161394f4ce78f5ae Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Wed, 3 Aug 2022 11:38:43 -0300 Subject: [PATCH] feat(core): improve tray icon read error messages (#4850) --- .changes/improve-tray-errors.md | 5 +++++ core/tauri-codegen/src/context.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changes/improve-tray-errors.md diff --git a/.changes/improve-tray-errors.md b/.changes/improve-tray-errors.md new file mode 100644 index 000000000..e2fbb0400 --- /dev/null +++ b/.changes/improve-tray-errors.md @@ -0,0 +1,5 @@ +--- +"tauri-codegen": patch +--- + +Improve tray icon read error message. diff --git a/core/tauri-codegen/src/context.rs b/core/tauri-codegen/src/context.rs index 70518ef17..ac3786419 100644 --- a/core/tauri-codegen/src/context.rs +++ b/core/tauri-codegen/src/context.rs @@ -420,14 +420,14 @@ fn ico_icon>( let path = path.as_ref(); let bytes = std::fs::read(&path) - .unwrap_or_else(|_| panic!("failed to read icon {}", path.display())) + .unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e)) .to_vec(); let icon_dir = ico::IconDir::read(std::io::Cursor::new(bytes)) - .unwrap_or_else(|_| panic!("failed to parse icon {}", path.display())); + .unwrap_or_else(|e| panic!("failed to parse icon {}: {}", path.display(), e)); let entry = &icon_dir.entries()[0]; let rgba = entry .decode() - .unwrap_or_else(|_| panic!("failed to decode icon {}", path.display())) + .unwrap_or_else(|e| panic!("failed to decode icon {}: {}", path.display(), e)) .rgba_data() .to_vec(); let width = entry.width(); @@ -459,7 +459,7 @@ fn raw_icon>(out_dir: &Path, path: P) -> Result>( let path = path.as_ref(); let bytes = std::fs::read(&path) - .unwrap_or_else(|_| panic!("failed to read icon {}", path.display())) + .unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e)) .to_vec(); let decoder = png::Decoder::new(std::io::Cursor::new(bytes)); let mut reader = decoder .read_info() - .unwrap_or_else(|_| panic!("failed to read icon {}", path.display())); + .unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e)); let mut buffer: Vec = Vec::new(); while let Ok(Some(row)) = reader.next_row() { buffer.extend(row.data());