Skip to main content

bamboo_agent/agent/llm/protocol/
errors.rs

1//! Error types for protocol conversion.
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum ProtocolError {
7    #[error("Serialization error: {0}")]
8    Serialization(#[from] serde_json::Error),
9
10    #[error("Invalid role: {0}")]
11    InvalidRole(String),
12
13    #[error("Invalid content format: {0}")]
14    InvalidContent(String),
15
16    #[error("Missing required field: {0}")]
17    MissingField(String),
18
19    #[error("Unsupported feature '{feature}' for protocol '{protocol}'")]
20    UnsupportedFeature { feature: String, protocol: String },
21
22    #[error("Invalid tool call: {0}")]
23    InvalidToolCall(String),
24
25    #[error("Invalid stream chunk: {0}")]
26    InvalidStreamChunk(String),
27
28    #[error("Protocol conversion error: {0}")]
29    Conversion(String),
30}
31
32pub type ProtocolResult<T> = Result<T, ProtocolError>;