1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, CoreError>;
7
8#[derive(Debug, Error)]
10pub enum CoreError {
11 #[error("tool error: {0}")]
13 Tool(String),
14
15 #[error("memory error: {0}")]
17 Memory(String),
18
19 #[error("governance violation: {0}")]
21 Governance(String),
22
23 #[error("rate limited: {0}")]
25 RateLimited(String),
26
27 #[error("circuit breaker open for: {0}")]
29 CircuitBreaker(String),
30
31 #[error("invalid args: {0}")]
33 InvalidArgs(String),
34
35 #[error("not found: {0}")]
37 NotFound(String),
38
39 #[error("polyglot error: {0}")]
41 Polyglot(String),
42
43 #[error("io error: {0}")]
45 Io(#[from] std::io::Error),
46
47 #[error("serialization error: {0}")]
49 Serde(#[from] serde_json::Error),
50
51 #[error("internal error: {0}")]
53 Internal(String),
54}
55
56impl CoreError {
57 #[must_use]
59 pub const fn is_retryable(&self) -> bool {
60 matches!(self, Self::RateLimited(_) | Self::CircuitBreaker(_))
61 }
62
63 #[must_use]
65 pub const fn is_governance(&self) -> bool {
66 matches!(self, Self::Governance(_))
67 }
68}