1use hopr_api::types::primitive::errors::GeneralError;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
6pub enum StrategyError {
7 #[error("criteria to trigger the strategy were not satisfied")]
8 CriteriaNotSatisfied,
9
10 #[error("strategy could not perform action because action of the same type is on-going")]
11 InProgress,
12
13 #[error("non-specific strategy error: {0}")]
14 Other(anyhow::Error),
15
16 #[error("HOPR error: {0}")]
17 HoprError(anyhow::Error),
18
19 #[error("lower-level error: {0}")]
20 GeneralError(#[from] GeneralError),
21}
22
23impl StrategyError {
24 pub fn other<E: Into<anyhow::Error>>(e: E) -> Self {
25 StrategyError::Other(e.into())
26 }
27}
28
29pub type Result<T> = std::result::Result<T, StrategyError>;