hopr_primitive_types/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use serde::{Deserialize, Serialize};
use thiserror::Error;

/// Type for any possible error, because the traits in this module
/// can be used in with any possible contexts (and error types).
pub type AnyError = Box<dyn std::error::Error + Send + Sync + 'static>;

/// Listing of some general re-usable errors
#[derive(Error, Debug, Serialize, Deserialize, PartialEq)]
pub enum GeneralError {
    #[error("failed to parse/deserialize the data: {0}")]
    ParseError(String),

    #[error("input argument to the function is invalid")]
    InvalidInput,

    #[error("non-specific error: {0}")]
    NonSpecificError(String),
}

pub type Result<T> = core::result::Result<T, GeneralError>;