mirror of
https://github.com/tauri-apps/tauri.git
synced 2025-01-01 23:42:33 +03:00
feat(core): improve tray icon read error messages (#4850)
This commit is contained in:
parent
fa23310f23
commit
52f0c8bb83
5
.changes/improve-tray-errors.md
Normal file
5
.changes/improve-tray-errors.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-codegen": patch
|
||||
---
|
||||
|
||||
Improve tray icon read error message.
|
@ -420,14 +420,14 @@ fn ico_icon<P: AsRef<Path>>(
|
||||
|
||||
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<P: AsRef<Path>>(out_dir: &Path, path: P) -> Result<TokenStream, Embe
|
||||
|
||||
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 out_path = out_dir.join(path.file_name().unwrap());
|
||||
@ -491,12 +491,12 @@ fn png_icon<P: AsRef<Path>>(
|
||||
|
||||
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<u8> = Vec::new();
|
||||
while let Ok(Some(row)) = reader.next_row() {
|
||||
buffer.extend(row.data());
|
||||
|
Loading…
Reference in New Issue
Block a user