use std::path::PathBuf; #[derive(Debug, thiserror::Error)] pub enum BumperError { #[error("Can't figure out what kind of project: {0}")] UnknownProjectKind(PathBuf), #[error("Couldn't read file {0}: {1}")] Read(PathBuf, #[source] std::io::Error), #[error("Couldn't write file {0}: {1}")] Write(PathBuf, #[source] std::io::Error), #[error("Couldn't find Cargo.toml in {0}: {1}")] CargoTomlNotFound(PathBuf, #[source] cargo_edit::Error), #[error("Couldn't parse Cargo.toml from {0}: {1}")] FromToml(PathBuf, #[source] cargo_edit::Error), #[error("Couldn't create Cargo.toml manifest to {0}: {1}")] WriteToml(PathBuf, #[source] cargo_edit::Error), #[error("Cargo.toml doesn't have a 'package' table")] NoPackage(#[source] cargo_edit::Error), #[error("'project' in Cargo.toml is not a table")] ProjectNotTable, #[error("Cargo.toml doesn't specify a package name")] UnnamedProject, #[error("Couldn't turn {0} into an absolute path: {1}")] AbsPath(PathBuf, #[source] std::io::Error), #[error("Failed to run git: {0}")] GitInvoke(#[source] std::io::Error), #[error("Command 'git tag' failed: {0}")] GitTag(String), } impl BumperError { pub fn git_tag(stderr: &[u8]) -> Self { let stderr = String::from_utf8_lossy(stderr).into_owned(); Self::GitTag(stderr) } }