1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
//! This file implements the error type for the crate.
use graph::error::Error as GError;
use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub enum Error {
UnknownNode(usize),
UnsupportedOperation,
Graph(GError),
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Error::UnknownNode(id) => write!(f, "unknown node: {id}"),
Error::UnsupportedOperation => write!(f, "unsupported operation"),
Error::Graph(e) => write!(f, "graph error: {e}"),
}
}
}
impl std::error::Error for Error {}
impl From<GError> for Error {
fn from(e: GError) -> Self {
Self::Graph(e)
}
}
|