hopr_path/
errors.rs

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
31
32
33
34
35
use hopr_db_api::errors::DbError;
use hopr_primitive_types::errors::GeneralError;
use thiserror::Error;

/// Enumerates all errors in this crate.
#[derive(Error, Debug)]
pub enum PathError {
    #[error("path is not valid")]
    PathNotValid,

    #[error("path contains an invalid peer id: {0}")]
    InvalidPeer(String),

    #[error("missing channel between {0} and {1}")]
    MissingChannel(String, String),

    #[error("channel between {0} and {1} is not opened")]
    ChannelNotOpened(String, String),

    #[error("path contains loop on {0}")]
    LoopsNotAllowed(String),

    #[error("cannot find {0} hop path {1} -> {2} in the channel graph")]
    PathNotFound(usize, String, String),

    // #[error(transparent)]
    // DatabaseError(#[from] DbSqlError),
    #[error(transparent)]
    DbError(#[from] DbError),

    #[error(transparent)]
    OtherError(#[from] GeneralError),
}

pub type Result<T> = std::result::Result<T, PathError>;