1use thiserror::Error;
2
3#[derive(Debug, Error)]
5pub enum CoreError {
6 #[error("position not found: {0}")]
7 PositionNotFound(String),
8
9 #[error("group not found: {0}")]
10 GroupNotFound(String),
11
12 #[error("invalid action: {0}")]
13 InvalidAction(String),
14
15 #[error("take-profit target {price} not found for position {position_id}")]
16 TargetNotFound { position_id: String, price: f64 },
17
18 #[error("take-profit target {price} has already triggered for position {position_id}")]
19 TargetAlreadyTriggered { position_id: String, price: f64 },
20
21 #[error("no price available for symbol: {0}")]
22 NoPriceAvailable(String),
23
24 #[error("position not in expected state: id={id}, expected={expected}, actual={actual}")]
25 InvalidState {
26 id: String,
27 expected: String,
28 actual: String,
29 },
30
31 #[error("{0}")]
32 Other(String),
33}
34
35pub type Result<T> = std::result::Result<T, CoreError>;