diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2021-11-24 21:15:39 +0100 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2021-11-24 21:15:39 +0100 |
commit | a96f86710eaabe5ae8c235ca537ad5b156884fc9 (patch) | |
tree | 0d531c085989bf0f5b4a2aa134a7645297231041 /src | |
parent | b4aadcde1ccf9021f7f47b3d8453faa333850e76 (diff) | |
download | vtcol-a96f86710eaabe5ae8c235ca537ad5b156884fc9.tar.gz |
don’t panic!() on open(2) failure
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) } |