use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum RustinelError {
#[error("I/O error while reading {path}")]
Io {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("Could not parse Cargo.lock at {path}: {message}")]
LockfileParse { path: PathBuf, message: String },
#[error("Invalid policy: {0}")]
InvalidPolicy(String),
#[error("Could not load advisory database at {path}: {message}")]
AdvisoryDb { path: PathBuf, message: String },
}
impl RustinelError {
pub fn io(path: impl Into<PathBuf>, source: std::io::Error) -> Self {
Self::Io {
path: path.into(),
source,
}
}
pub fn lockfile_parse(path: impl Into<PathBuf>, message: impl Into<String>) -> Self {
Self::LockfileParse {
path: path.into(),
message: message.into(),
}
}
}