diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -545,18 +545,18 @@ impl Palette pub fn from_file(fname: &Path) -> io::Result<Self> { - /* Check if file exists - */ - let file = match std::fs::File::open(&fname) { - Err(e) => { - panic!("failed to open {} as file ({})", fname.display(), e) - }, - Ok(f) => f, - }; + let file = std::fs::File::open(&fname).map_err(|e| { + io::Error::new( + io::ErrorKind::Other, + format!( + "failed to open palette specification {}: {}", + fname.display(), + e + ), + ) + })?; let mut reader = std::io::BufReader::new(file); - /* Parse scheme file - */ Self::from_buffered_reader(&mut reader) } |