use std::fmt;
/// A failure that stops a pipeline: a stable `code` and a message for people.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Error {
pub code: String,
pub message: String,
}
impl Error {
pub fn new(code: impl Into<String>, message: impl Into<String>) -> Self {
Self {
code: code.into(),
message: message.into(),
}
}
}
impl fmt::Display for Error {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "{}: {}", self.code, self.message)
}
}
impl std::error::Error for Error {}