use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Graph(prov_graph::error::Error),
View(prov_views::Error),
ViewUnknown {
export: String,
view: String,
},
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Graph(e) => write!(f, "{e}"),
Error::View(e) => write!(f, "{e}"),
Error::ViewUnknown { export, view } => write!(
f,
"the export `{export}` is arranged by the view `{view}`, \
but this workspace declares no view by that name"
),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::Graph(e) => Some(e),
Error::View(e) => Some(e),
Error::ViewUnknown { .. } => None,
}
}
}
impl From<prov_graph::error::Error> for Error {
fn from(error: prov_graph::error::Error) -> Self {
Error::Graph(error)
}
}
impl From<prov_views::Error> for Error {
fn from(error: prov_views::Error) -> Self {
Error::View(error)
}
}