ferro_ai/error.rs
1/// Errors that can occur in ferro-ai operations.
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4 /// Configuration error (missing env var or invalid value).
5 #[error("ai config error: {0}")]
6 Config(String),
7
8 /// AI provider API call failed.
9 #[error("ai provider error: {0}")]
10 Provider(String),
11
12 /// Classification returned confidence below the configured threshold.
13 #[error("low confidence classification (confidence: {confidence:.2})")]
14 LowConfidence {
15 /// The best guess returned by the provider.
16 best_guess: serde_json::Value,
17 /// The confidence score (0.0–1.0).
18 confidence: f64,
19 },
20
21 /// Failed to deserialize the provider response into the target type.
22 #[error("deserialization error: {0}")]
23 Deserialization(String),
24
25 /// Request timed out after all retries were exhausted.
26 #[error("classification request timed out after retries")]
27 Timeout,
28
29 /// Confirmation store operation failed.
30 #[error("confirmation store error: {0}")]
31 StoreError(String),
32}