Skip to main content

atomr_agents_coding_cli_core/
error.rs

1//! Errors produced by vendor adapters.
2
3use thiserror::Error;
4
5/// A vendor-side stream parser failed to interpret a line.
6#[derive(Debug, Error)]
7pub enum ParseError {
8    #[error("malformed json: {0}")]
9    Json(#[from] serde_json::Error),
10
11    #[error("unsupported event shape: {0}")]
12    Unsupported(String),
13
14    #[error("missing required field: {0}")]
15    MissingField(&'static str),
16
17    #[error("invalid value for {field}: {message}")]
18    InvalidValue { field: &'static str, message: String },
19}
20
21/// A vendor adapter failed to project atomr concepts onto its on-disk
22/// config (`CLAUDE.md`, `.cursor/rules/*`, `AGENTS.md`, MCP, ...).
23#[derive(Debug, Error)]
24pub enum MapperError {
25    #[error("filesystem error at {path}: {source}")]
26    Io {
27        path: String,
28        #[source]
29        source: std::io::Error,
30    },
31
32    #[error("serialization failed: {0}")]
33    Serde(#[from] serde_json::Error),
34
35    #[error("vendor does not support concept {0}")]
36    Unsupported(&'static str),
37}
38
39impl MapperError {
40    pub fn io(path: impl Into<String>, source: std::io::Error) -> Self {
41        Self::Io {
42            path: path.into(),
43            source,
44        }
45    }
46}