sentinel_agent_protocol/
errors.rs

1//! Agent protocol error types.
2
3use std::time::Duration;
4use thiserror::Error;
5
6/// Agent protocol errors
7#[derive(Error, Debug)]
8pub enum AgentProtocolError {
9    #[error("Connection failed: {0}")]
10    ConnectionFailed(String),
11
12    #[error("Connection closed")]
13    ConnectionClosed,
14
15    #[error("Protocol version mismatch: expected {expected}, got {actual}")]
16    VersionMismatch { expected: u32, actual: u32 },
17
18    #[error("Message too large: {size} bytes (max: {max}")]
19    MessageTooLarge { size: usize, max: usize },
20
21    #[error("Invalid message format: {0}")]
22    InvalidMessage(String),
23
24    #[error("Timeout after {0:?}")]
25    Timeout(Duration),
26
27    #[error("Agent unavailable")]
28    Unavailable,
29
30    #[error("IO error: {0}")]
31    Io(#[from] std::io::Error),
32
33    #[error("Serialization error: {0}")]
34    Serialization(String),
35
36    #[error("Wrong connection type: {0}")]
37    WrongConnectionType(String),
38
39    #[error("Flow control paused: agent '{agent_id}' requested backpressure")]
40    FlowControlPaused { agent_id: String },
41}