use thiserror::Error;
pub type Result<T> = std::result::Result<T, CoreError>;
#[derive(Debug, Error)]
pub enum CoreError {
#[error("tool error: {0}")]
Tool(String),
#[error("memory error: {0}")]
Memory(String),
#[error("governance violation: {0}")]
Governance(String),
#[error("rate limited: {0}")]
RateLimited(String),
#[error("circuit breaker open for: {0}")]
CircuitBreaker(String),
#[error("invalid args: {0}")]
InvalidArgs(String),
#[error("not found: {0}")]
NotFound(String),
#[error("polyglot error: {0}")]
Polyglot(String),
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("serialization error: {0}")]
Serde(#[from] serde_json::Error),
#[error("internal error: {0}")]
Internal(String),
}
impl CoreError {
#[must_use]
pub const fn is_retryable(&self) -> bool {
matches!(self, Self::RateLimited(_) | Self::CircuitBreaker(_))
}
#[must_use]
pub const fn is_governance(&self) -> bool {
matches!(self, Self::Governance(_))
}
}