hypercall_margin/
error.rs1use rust_decimal::Decimal;
2
3#[derive(Debug, Clone)]
4pub enum MarginError {
5 InvalidStrike {
6 underlying: String,
7 strike: Decimal,
8 },
9 NonRepresentableDecimal {
10 field: &'static str,
11 underlying: String,
12 },
13}
14
15impl std::fmt::Display for MarginError {
16 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17 match self {
18 Self::InvalidStrike { underlying, strike } => {
19 write!(
20 f,
21 "invalid strike {strike} for underlying {underlying} in margin calculation"
22 )
23 }
24 Self::NonRepresentableDecimal { field, underlying } => {
25 write!(
26 f,
27 "non-representable decimal field {field} for underlying {underlying}"
28 )
29 }
30 }
31 }
32}
33
34impl std::error::Error for MarginError {}