cel_brief/error.rs
1//! Error type for `cel-brief`.
2
3use thiserror::Error;
4
5/// Top-level error returned by `BriefBuilder` operations.
6#[derive(Error, Debug)]
7pub enum BriefError {
8 /// One of the configured sources failed to contribute.
9 #[error("source `{source_id}` failed: {message}")]
10 Source {
11 /// Identifier of the source that failed.
12 source_id: String,
13 /// Underlying error message.
14 message: String,
15 },
16
17 /// Governance rejected the draft brief.
18 #[error("brief rejected by governance: {0}")]
19 Rejected(String),
20
21 /// Token budget could not be satisfied even after pruning to priority floors.
22 #[error("token budget unsatisfiable: needed at least {needed}, had {available}")]
23 BudgetUnsatisfiable {
24 /// Tokens still required after pruning.
25 needed: usize,
26 /// Tokens available under the configured budget.
27 available: usize,
28 },
29
30 /// A source operation timed out.
31 #[error("source `{source_id}` timed out after {timeout_ms}ms")]
32 Timeout {
33 /// Identifier of the source that timed out.
34 source_id: String,
35 /// Configured timeout in milliseconds.
36 timeout_ms: u64,
37 },
38}
39
40/// Convenience alias for `Result<T, BriefError>`.
41pub type Result<T> = std::result::Result<T, BriefError>;