1use std::fmt;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug)]
10pub enum Error {
11 Graph(prov_graph::error::Error),
13 AnchorUnresolved {
18 view: String,
20 under: String,
22 why: String,
24 },
25}
26
27impl fmt::Display for Error {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 match self {
30 Error::Graph(e) => write!(f, "{e}"),
31 Error::AnchorUnresolved { view, under, why } => write!(
32 f,
33 "the view `{view}` is anchored under `{under}`, but {why}"
34 ),
35 }
36 }
37}
38
39impl std::error::Error for Error {
40 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
41 match self {
42 Error::Graph(e) => Some(e),
43 Error::AnchorUnresolved { .. } => None,
44 }
45 }
46}
47
48impl From<prov_graph::error::Error> for Error {
49 fn from(error: prov_graph::error::Error) -> Self {
50 Error::Graph(error)
51 }
52}