llm_budget_window/error.rs
1//! Error type.
2
3use thiserror::Error;
4
5/// Raised by `BudgetWindows::record` when a record would push any
6/// window's running total past its cap.
7#[derive(Debug, Error)]
8#[error(
9 "window {window_name:?} on axis {axis} would breach: attempted {attempted:.6} > cap {cap:.6}"
10)]
11pub struct WindowBreached {
12 /// Name of the window that breached (the first one if multiple).
13 pub window_name: String,
14 /// "tokens" or "usd".
15 pub axis: &'static str,
16 /// Running total + record delta.
17 pub attempted: f64,
18 /// The configured cap on that axis.
19 pub cap: f64,
20}