Skip to main content

agent_block_types/
error.rs

1//! Typed error types for agent-block internals.
2//!
3//! All library/internal code uses `BlockError`.
4//! Only `main.rs` converts to `anyhow::Error` for CLI output.
5
6#[derive(Debug, thiserror::Error)]
7pub enum BlockError {
8    #[error("MCP error: {0}")]
9    Mcp(String),
10
11    #[error("mesh error: {0}")]
12    Mesh(String),
13
14    #[error("I/O error: {0}")]
15    Io(#[from] std::io::Error),
16
17    #[error("JSON error: {0}")]
18    Json(#[from] serde_json::Error),
19
20    #[error("script error: {0}")]
21    Script(String),
22
23    #[error("timeout: {0}")]
24    Timeout(String),
25
26    #[error("runtime error: {0}")]
27    Runtime(String),
28
29    // Used by `crate::bus` (dispatcher + event) and `bridge::bus`.
30    #[error("bus error: {0}")]
31    Bus(String),
32}
33
34pub type BlockResult<T> = Result<T, BlockError>;