1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
7pub enum RustinelError {
8 #[error("I/O error while reading {path}")]
11 Io {
12 path: PathBuf,
13 #[source]
14 source: std::io::Error,
15 },
16
17 #[error("Could not parse Cargo.lock at {path}: {message}")]
18 LockfileParse { path: PathBuf, message: String },
19
20 #[error("Invalid policy: {0}")]
21 InvalidPolicy(String),
22
23 #[error("Could not load advisory database at {path}: {message}")]
24 AdvisoryDb { path: PathBuf, message: String },
25}
26
27impl RustinelError {
28 pub fn io(path: impl Into<PathBuf>, source: std::io::Error) -> Self {
29 Self::Io {
30 path: path.into(),
31 source,
32 }
33 }
34
35 pub fn lockfile_parse(path: impl Into<PathBuf>, message: impl Into<String>) -> Self {
36 Self::LockfileParse {
37 path: path.into(),
38 message: message.into(),
39 }
40 }
41}