use std::fmt;
use thiserror::Error;
#[derive(Debug)]
pub struct FileOpsError(pub(crate) std::io::Error);
impl fmt::Display for FileOpsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "filesystem error: {}", self.0)
}
}
impl std::error::Error for FileOpsError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(&self.0)
}
}
impl From<std::io::Error> for FileOpsError {
fn from(err: std::io::Error) -> Self {
FileOpsError(err)
}
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("unknown palette {palette:?}{context}")]
UnknownPalette {
palette: String,
context: String,
},
#[error("unknown shade {shade}{context}")]
UnknownShade {
shade: u32,
context: String,
},
#[error("invalid color {color:?}: {source}")]
InvalidColor {
color: String,
#[source]
source: csscolorparser::ParseColorError,
},
#[error("invalid gradient {name:?}: {message}")]
InvalidGradient {
name: String,
message: String,
},
#[error("invalid position {0:?}: {1}")]
InvalidPosition(String, String),
#[error("invalid gradient stop {0:?}: {1}")]
InvalidGradientStop(String, String),
#[error("scale mismatch: {0}")]
ScaleMismatch(String),
#[cfg(feature = "cli")]
#[error(transparent)]
Io(#[from] FileOpsError),
}