1use crate::{providers::ProviderError, sandbox::SandboxError, skills::SkillError};
2use serde::{Deserialize, Serialize};
3
4#[derive(thiserror::Error, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
5pub enum StorageError {
6 #[error("storage io error: {0}")]
7 Io(String),
8 #[error("storage serialization error: {0}")]
9 Serde(String),
10 #[error("storage unavailable: {0}")]
11 Unavailable(String),
12 #[error("storage not found: {0}")]
13 NotFound(String),
14 #[error("storage internal error: {0}")]
15 Internal(String),
16}
17
18impl StorageError {
19 pub fn io(error: impl Into<String>) -> Self {
20 Self::Io(error.into())
21 }
22
23 pub fn serde(error: impl Into<String>) -> Self {
24 Self::Serde(error.into())
25 }
26
27 pub fn unavailable(error: impl Into<String>) -> Self {
28 Self::Unavailable(error.into())
29 }
30
31 pub fn internal(error: impl Into<String>) -> Self {
32 Self::Internal(error.into())
33 }
34}
35
36#[derive(thiserror::Error, Debug)]
37pub enum AgentError {
38 #[error("storage error: {0}")]
39 Storage(#[from] StorageError),
40 #[error("provider error: {0}")]
41 Provider(#[from] ProviderError),
42 #[error("sandbox error: {0}")]
43 Sandbox(#[from] SandboxError),
44 #[error("skill error: {0}")]
45 Skill(#[from] SkillError),
46 #[error("config error: {0}")]
47 Config(String),
48 #[error("internal error: {0}")]
49 Internal(String),
50}
51
52impl AgentError {
53 pub fn config(message: impl Into<String>) -> Self {
54 Self::Config(message.into())
55 }
56
57 pub fn internal(message: impl Into<String>) -> Self {
58 Self::Internal(message.into())
59 }
60}