grid_billing/error.rs
1//! Error types for `mako-nne`.
2
3/// Errors returned by the billing calculation functions.
4#[derive(Debug, Clone, thiserror::Error)]
5pub enum BillingError {
6 /// The billing input contains an invalid or inconsistent value.
7 #[error("invalid billing input: {reason}")]
8 InvalidInput {
9 /// Human-readable explanation. Dynamic `String` so callers can include runtime context.
10 reason: String,
11 },
12
13 /// Monetary precision overflow — the calculated amount exceeds `i64` range.
14 ///
15 /// This can only happen for unrealistically large billing amounts (> ~92 million EUR).
16 /// `input_value` carries the `Decimal` that caused the overflow so callers can log it.
17 #[error("monetary overflow: amount {input_value:?} too large for EuroAmount representation")]
18 MonetaryOverflow {
19 /// The value that caused the overflow, if available.
20 input_value: Option<rust_decimal::Decimal>,
21 },
22}