use thiserror::Error;
pub mod prelude {
pub use super::CnfError;
pub use anyhow::{anyhow, Context};
pub type Result<T> = std::result::Result<T, CnfError>;
}
#[derive(Error, Debug)]
pub enum CnfError {
#[error("{provider} in {env}: {error}")]
Provider {
provider: crate::provider::Provider,
env: std::sync::Arc<crate::environment::Environment>,
error: crate::provider::Error,
},
#[error("couldn't read configuration")]
Config(String),
#[error("command not found: '{0}'")]
NotFound(String),
#[error("unknown execution environment!")]
UnknownEnvironment,
#[error("illegal execution environment: {0}")]
IllegalEnvironment(String),
#[error("executing '{cmd}' in environment '{env}' failed: '{error:?}'")]
Execution {
cmd: String,
env: String,
error: std::process::Output,
},
#[error("requirement '{requires}' not fulfilled for provider '{provider}' in '{env}'")]
Requirements {
requires: String,
provider: String,
env: String,
},
#[error(transparent)]
ApplicationError(#[from] anyhow::Error),
#[error("please implement '{0}' first!")]
NotImplemented(String),
#[error("an error occured while {action}: '{error}'")]
Other { action: String, error: String },
}