use std::path::PathBuf;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("could not read {path}: {source}")]
Io {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("invalid YAML in {path}: {source}")]
Yaml {
path: PathBuf,
#[source]
source: serde_yaml::Error,
},
#[error("invalid test definition: {0}")]
Invalid(String),
#[error("provider error ({context}): {message}")]
Provider {
context: String,
message: String,
kind: Option<String>,
},
#[error("skill validation failed with {} finding(s)", .0.len())]
Validation(Vec<String>),
}
impl Error {
pub fn provider(context: impl Into<String>, message: impl std::fmt::Display) -> Self {
Error::Provider {
context: context.into(),
message: message.to_string(),
kind: None,
}
}
pub fn provider_classified(
context: impl Into<String>,
message: impl std::fmt::Display,
kind: impl Into<String>,
) -> Self {
Error::Provider {
context: context.into(),
message: message.to_string(),
kind: Some(kind.into()),
}
}
}