coalescent 0.1.0

High-level AI coordination patterns enabling intelligent agent coalescence
Documentation
//! Error types for the Coalescent library

use thiserror::Error;

/// Result type alias for Coalescent operations
pub type Result<T> = std::result::Result<T, CoalescentError>;

/// Errors that can occur during AI coordination
#[derive(Error, Debug)]
pub enum CoalescentError {
    /// Agent-related errors
    #[error("Agent error: {0}")]
    Agent(String),
    
    /// Coordination errors
    #[error("Coordination failed: {0}")]
    Coordination(String),
    
    /// Task-related errors
    #[error("Task error: {0}")]
    Task(String),
    
    /// Trust system errors
    #[error("Trust evaluation failed: {0}")]
    Trust(String),
    
    /// Configuration errors
    #[error("Configuration error: {0}")]
    Config(String),
    
    /// Serialization errors
    #[error("Serialization error: {0}")]
    Serialization(#[from] serde_json::Error),
    
    /// Generic error for external integrations
    #[error("External error: {0}")]
    External(#[from] anyhow::Error),
}

impl CoalescentError {
    /// Create a new agent error
    pub fn agent<S: Into<String>>(msg: S) -> Self {
        Self::Agent(msg.into())
    }
    
    /// Create a new coordination error
    pub fn coordination<S: Into<String>>(msg: S) -> Self {
        Self::Coordination(msg.into())
    }
    
    /// Create a new task error
    pub fn task<S: Into<String>>(msg: S) -> Self {
        Self::Task(msg.into())
    }
    
    /// Create a new trust error
    pub fn trust<S: Into<String>>(msg: S) -> Self {
        Self::Trust(msg.into())
    }
    
    /// Create a new configuration error
    pub fn config<S: Into<String>>(msg: S) -> Self {
        Self::Config(msg.into())
    }
}