rshyper_algo/
error.rs

1/*
2    Appellation: error <module>
3    Contrib: @FL03
4*/
5//! this module implements the [`Error`] type for algorithms and operators for hypergraphs in
6//! the [`rshyper`](https://docs.rs/rshyper) crate.
7
8#[cfg(feature = "alloc")]
9use alloc::boxed::Box;
10use rshyper::error::Error as CoreError;
11use rshyper::idx::RawIndex;
12/// a type alias for a [Result] with the crate-specific error type [`AlgoError`]
13pub type Result<T = ()> = core::result::Result<T, Error>;
14
15/// The [`Error`] type enumerates the various errors encountered by algorithms and operators on
16/// hypergraphs
17#[derive(Debug, strum::EnumIs, thiserror::Error)]
18pub enum Error {
19    #[cfg(feature = "alloc")]
20    #[error("Not Found: {0}")]
21    NotFound(Box<dyn RawIndex>),
22    #[error("No path found between the two points")]
23    PathNotFound,
24    #[error(transparent)]
25    CoreError(#[from] CoreError),
26}
27
28#[cfg(feature = "alloc")]
29impl From<Error> for CoreError {
30    fn from(e: Error) -> Self {
31        match e {
32            Error::CoreError(e) => e,
33            _ => CoreError::BoxError(Box::new(e)),
34        }
35    }
36}