Skip to main content

atomr_agents_coding_cli_harness/
error.rs

1use thiserror::Error;
2
3use atomr_agents_coding_cli_core::{CliVendorKind, MapperError, ParseError};
4use atomr_agents_coding_cli_isolator::IsolatorError;
5
6#[derive(Debug, Error)]
7pub enum HarnessError {
8    #[error("unknown vendor: {0}")]
9    UnknownVendor(CliVendorKind),
10
11    #[error("vendor not available locally: {0}")]
12    VendorUnavailable(CliVendorKind),
13
14    #[error("invalid request: {0}")]
15    InvalidRequest(String),
16
17    #[error("workdir is missing or not a directory: {0}")]
18    InvalidWorkdir(String),
19
20    #[error("session not found: {0}")]
21    SessionNotFound(String),
22
23    #[error(transparent)]
24    Mapper(#[from] MapperError),
25
26    #[error(transparent)]
27    Isolator(#[from] IsolatorError),
28
29    #[error("parse error: {0}")]
30    Parse(#[from] ParseError),
31
32    #[error("serialization error: {0}")]
33    Serde(#[from] serde_json::Error),
34
35    #[error("io error: {0}")]
36    Io(#[from] std::io::Error),
37
38    #[error("cancelled")]
39    Cancelled,
40}
41
42pub type Result<T, E = HarnessError> = std::result::Result<T, E>;
43
44impl From<HarnessError> for atomr_agents_core::AgentError {
45    fn from(e: HarnessError) -> Self {
46        atomr_agents_core::AgentError::Harness(e.to_string())
47    }
48}