use crate::{providers::ProviderError, sandbox::SandboxError, skills::SkillError};
use serde::{Deserialize, Serialize};
#[derive(thiserror::Error, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum StorageError {
#[error("storage io error: {0}")]
Io(String),
#[error("storage serialization error: {0}")]
Serde(String),
#[error("storage unavailable: {0}")]
Unavailable(String),
#[error("storage not found: {0}")]
NotFound(String),
#[error("storage internal error: {0}")]
Internal(String),
}
impl StorageError {
pub fn io(error: impl Into<String>) -> Self {
Self::Io(error.into())
}
pub fn serde(error: impl Into<String>) -> Self {
Self::Serde(error.into())
}
pub fn unavailable(error: impl Into<String>) -> Self {
Self::Unavailable(error.into())
}
pub fn internal(error: impl Into<String>) -> Self {
Self::Internal(error.into())
}
}
#[derive(thiserror::Error, Debug)]
pub enum AgentError {
#[error("storage error: {0}")]
Storage(#[from] StorageError),
#[error("provider error: {0}")]
Provider(#[from] ProviderError),
#[error("sandbox error: {0}")]
Sandbox(#[from] SandboxError),
#[error("skill error: {0}")]
Skill(#[from] SkillError),
#[error("config error: {0}")]
Config(String),
#[error("internal error: {0}")]
Internal(String),
}
impl AgentError {
pub fn config(message: impl Into<String>) -> Self {
Self::Config(message.into())
}
pub fn internal(message: impl Into<String>) -> Self {
Self::Internal(message.into())
}
}