summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 2dee9ca..d0014a5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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)
}