Skip to main content

everruns_local/
error.rs

1// Error type for the local crate. Converts cleanly into the core
2// `AgentLoopError` so trait implementations can return `everruns_core::Result`.
3
4use everruns_core::error::AgentLoopError;
5
6#[derive(Debug, thiserror::Error)]
7pub enum LocalError {
8    #[error("sqlite error: {0}")]
9    Sqlite(#[from] rusqlite::Error),
10
11    #[error("serialization error: {0}")]
12    Serde(#[from] serde_json::Error),
13
14    #[error("configuration error: {0}")]
15    Config(String),
16
17    #[error("{0}")]
18    Other(String),
19}
20
21pub type LocalResult<T> = std::result::Result<T, LocalError>;
22
23impl From<LocalError> for AgentLoopError {
24    fn from(err: LocalError) -> Self {
25        match err {
26            LocalError::Config(msg) => AgentLoopError::config(msg),
27            other => AgentLoopError::store(other.to_string()),
28        }
29    }
30}