Skip to content

Commit 52f0c8b

Browse files
authored
feat(core): improve tray icon read error messages (#4850)
1 parent fa23310 commit 52f0c8b

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎.changes/improve-tray-errors.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-codegen": patch
3+
---
4+
5+
Improve tray icon read error message.

‎core/tauri-codegen/src/context.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,14 @@ fn ico_icon<P: AsRef<Path>>(
420420

421421
let path = path.as_ref();
422422
let bytes = std::fs::read(&path)
423-
.unwrap_or_else(|_| panic!("failed to read icon {}", path.display()))
423+
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
424424
.to_vec();
425425
let icon_dir = ico::IconDir::read(std::io::Cursor::new(bytes))
426-
.unwrap_or_else(|_| panic!("failed to parse icon {}", path.display()));
426+
.unwrap_or_else(|e| panic!("failed to parse icon {}: {}", path.display(), e));
427427
let entry = &icon_dir.entries()[0];
428428
let rgba = entry
429429
.decode()
430-
.unwrap_or_else(|_| panic!("failed to decode icon {}", path.display()))
430+
.unwrap_or_else(|e| panic!("failed to decode icon {}: {}", path.display(), e))
431431
.rgba_data()
432432
.to_vec();
433433
let width = entry.width();
@@ -459,7 +459,7 @@ fn raw_icon<P: AsRef<Path>>(out_dir: &Path, path: P) -> Result<TokenStream, Embe
459459

460460
let path = path.as_ref();
461461
let bytes = std::fs::read(&path)
462-
.unwrap_or_else(|_| panic!("failed to read icon {}", path.display()))
462+
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
463463
.to_vec();
464464

465465
let out_path = out_dir.join(path.file_name().unwrap());
@@ -491,12 +491,12 @@ fn png_icon<P: AsRef<Path>>(
491491

492492
let path = path.as_ref();
493493
let bytes = std::fs::read(&path)
494-
.unwrap_or_else(|_| panic!("failed to read icon {}", path.display()))
494+
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
495495
.to_vec();
496496
let decoder = png::Decoder::new(std::io::Cursor::new(bytes));
497497
let mut reader = decoder
498498
.read_info()
499-
.unwrap_or_else(|_| panic!("failed to read icon {}", path.display()));
499+
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e));
500500
let mut buffer: Vec<u8> = Vec::new();
501501
while let Ok(Some(row)) = reader.next_row() {
502502
buffer.extend(row.data());

0 commit comments

Comments
 (0)