gcp_racoon/error.rs
1//! Application-level error types for racoon.
2//!
3//! This module defines a unified error enum that wraps all possible errors
4//! that can occur in the application. Following the Rust convention:
5//! - Libraries use `thiserror` for specific error types
6//! - Applications use `anyhow` for ad-hoc errors with context
7//!
8//! We use `thiserror` here to provide structured errors that can be
9//! pattern-matched by callers when needed.
10
11use thiserror::Error;
12
13/// Top-level application error type.
14///
15/// This enum captures all error categories that racoon can encounter.
16/// Each variant warps a more specific error type from the relevant module.
17#[derive(Error, Debug)]
18pub enum RacoonError {
19 /// GCP auth related errors
20 #[error("Authentication error: {0}")]
21 Auth(#[from] crate::gcp::auth::AuthError),
22
23 /// GCP logging API errors
24 #[error("Logging API error: {0}")]
25 Logs(#[from] crate::gcp::logs::LogsError),
26
27 /// AI/Gemini API errors
28 #[error("AI error: {0}")]
29 Ai(#[from] crate::ai::AiError),
30
31 /// Storage/IO errors
32 #[error("Storage error: {0}")]
33 Storage(#[from] std::io::Error),
34
35 /// Config errors
36 #[error("Configuration error: {0}")]
37 Config(String),
38}
39
40/// Result type alias for racoon operations.
41pub type Result<T> = std::result::Result<T, RacoonError>;