Skip to main content

feagi_agent/sdk/common/
error.rs

1//! Error types for the FEAGI agent.
2
3use std::error::Error;
4use std::fmt::{Display, Formatter};
5
6/// Errors that can occur in FEAGI agent operations.
7#[derive(Debug, Clone)]
8pub enum FeagiAgentError {
9    /// Authentication failed (invalid credentials, expired token, etc.)
10    AuthenticationFailed(String),
11    /// General failure (deserialization, parsing, validation, etc.)
12    GeneralFailure(String),
13}
14
15impl Display for FeagiAgentError {
16    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
17        match self {
18            FeagiAgentError::AuthenticationFailed(msg) => {
19                write!(f, "FeagiAgentError: Authentication failed: {}", msg)
20            }
21            FeagiAgentError::GeneralFailure(msg) => {
22                write!(f, "FeagiAgentError: {}", msg)
23            }
24        }
25    }
26}
27
28impl Error for FeagiAgentError {
29    fn source(&self) -> Option<&(dyn Error + 'static)> {
30        None
31    }
32}