fif/src/scan_error.rs

27 lines
569 B
Rust
Raw Normal View History

use std::fmt::{Display, Formatter, Result};
use std::path::PathBuf;
2021-02-21 14:07:50 +00:00
#[derive(Debug)]
pub enum ScanError {
/// Something went wrong while trying to read the given file.
File(PathBuf),
/// Failed to determine the mimetype of the given file.
Mime(PathBuf),
}
impl Display for ScanError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
2021-02-18 09:48:38 +00:00
write!(
f,
"Couldn't {} file: {}",
2021-02-18 09:48:38 +00:00
match self {
Self::File(_) => "read",
Self::Mime(_) => "determine mime type of",
},
match self {
Self::File(f) | Self::Mime(f) => f.to_string_lossy()
2021-02-18 09:48:38 +00:00
}
)
}
2021-02-18 09:48:38 +00:00
}