hopr_primitive_types/
errors.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// Type for any possible error, because the traits in this module
5/// can be used in with any possible contexts (and error types).
6pub type AnyError = Box<dyn std::error::Error + Send + Sync + 'static>;
7
8/// Listing of some general re-usable errors
9#[derive(Error, Debug, Serialize, Deserialize, PartialEq)]
10pub enum GeneralError {
11    #[error("failed to parse/deserialize the data: {0}")]
12    ParseError(String),
13
14    #[error("input argument to the function is invalid")]
15    InvalidInput,
16
17    #[error("non-specific error: {0}")]
18    NonSpecificError(String),
19}
20
21pub type Result<T> = core::result::Result<T, GeneralError>;