Skip to main content

graphrecords_core/errors/
mod.rs

1mod graph;
2mod graphrecord;
3
4pub use graph::GraphError;
5pub use graphrecord::GraphRecordError;
6
7impl From<GraphError> for GraphRecordError {
8    fn from(value: GraphError) -> Self {
9        match value {
10            GraphError::IndexError(value) => Self::IndexError(value),
11            GraphError::AssertionError(value) => Self::AssertionError(value),
12            GraphError::SchemaError(value) => Self::SchemaError(value),
13        }
14    }
15}
16
17pub type GraphRecordResult<T> = Result<T, GraphRecordError>;
18
19#[cfg(test)]
20mod test {
21    use super::{GraphError, GraphRecordError};
22
23    #[test]
24    fn test_from() {
25        assert_eq!(
26            GraphRecordError::IndexError("value".to_string()),
27            GraphRecordError::from(GraphError::IndexError("value".to_string()))
28        );
29        assert_eq!(
30            GraphRecordError::AssertionError("value".to_string()),
31            GraphRecordError::from(GraphError::AssertionError("value".to_string()))
32        );
33        assert_eq!(
34            GraphRecordError::SchemaError("value".to_string()),
35            GraphRecordError::from(GraphError::SchemaError("value".to_string()))
36        );
37    }
38}