use std::path::PathBuf;
#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
pub enum PkgError {
#[error("manifest parse error: {source}")]
ManifestParse {
#[from]
source: toml::de::Error,
},
#[error("lockfile parse error: {source}")]
LockfileParse { source: toml::de::Error },
#[error("lockfile write error: {source}")]
LockfileWrite {
#[from]
source: toml::ser::Error,
},
#[error("lockfile not found: {}", path.display())]
MissingLockfile { path: PathBuf },
#[error("duplicate package name in lockfile: {name:?}")]
SameNameConflict { name: String },
#[error("I/O error: {source}")]
Io {
#[from]
source: std::io::Error,
},
#[error("manifest validation error: {message}")]
Validation { message: String },
#[error("git fetch error: {source}")]
GitFetch {
#[from]
source: git2::Error,
},
#[error("tag SHA mismatch: expected {expected}, got {actual}")]
TagShaMismatch { expected: String, actual: String },
#[error("entry not found for {name:?}: tried {}", format_paths(attempted))]
EntryNotFound {
name: String,
attempted: Vec<PathBuf>,
},
}
fn format_paths(paths: &[PathBuf]) -> String {
paths
.iter()
.map(|p| p.display().to_string())
.collect::<Vec<_>>()
.join(", ")
}