use std::error::Error;
use std::fmt::{Display, Formatter, Result as FResult};
use std::path::PathBuf;
#[derive(Debug)]
pub enum RemoteVmError {
PlanError { err: brane_tsk::errors::PlanError },
ExecError { err: brane_exe::Error },
IllegalNodeConfig { path: PathBuf, got: String },
InfraFileLoad { path: PathBuf, err: brane_cfg::info::YamlError },
NodeConfigLoad { path: PathBuf, err: brane_cfg::info::YamlError },
}
impl Display for RemoteVmError {
fn fmt(&self, f: &mut Formatter<'_>) -> FResult {
use RemoteVmError::*;
match self {
PlanError { .. } => write!(f, "Failed to plan workflow"),
ExecError { .. } => write!(f, "Failed to execute workflow"),
IllegalNodeConfig { path, got } => {
write!(f, "Illegal node config kind in node config '{}'; expected Central, got {}", path.display(), got)
},
InfraFileLoad { path, .. } => write!(f, "Failed to load infra file '{}'", path.display()),
NodeConfigLoad { path, .. } => write!(f, "Failed to load node config file '{}'", path.display()),
}
}
}
impl Error for RemoteVmError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
use RemoteVmError::*;
match self {
PlanError { err } => Some(err),
ExecError { err } => Some(err),
IllegalNodeConfig { .. } => None,
InfraFileLoad { err, .. } => Some(err),
NodeConfigLoad { err, .. } => Some(err),
}
}
}