use thiserror::Error;
pub type Result<T> = std::result::Result<T, CoalescentError>;
#[derive(Error, Debug)]
pub enum CoalescentError {
#[error("Agent error: {0}")]
Agent(String),
#[error("Coordination failed: {0}")]
Coordination(String),
#[error("Task error: {0}")]
Task(String),
#[error("Trust evaluation failed: {0}")]
Trust(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("External error: {0}")]
External(#[from] anyhow::Error),
}
impl CoalescentError {
pub fn agent<S: Into<String>>(msg: S) -> Self {
Self::Agent(msg.into())
}
pub fn coordination<S: Into<String>>(msg: S) -> Self {
Self::Coordination(msg.into())
}
pub fn task<S: Into<String>>(msg: S) -> Self {
Self::Task(msg.into())
}
pub fn trust<S: Into<String>>(msg: S) -> Self {
Self::Trust(msg.into())
}
pub fn config<S: Into<String>>(msg: S) -> Self {
Self::Config(msg.into())
}
}