#[derive(Debug, Clone, PartialEq, thiserror::Error)]
pub enum AgentError {
#[error("API 请求失败: {0}")]
Api(String),
#[error("上下文操作失败: {0}")]
Context(String),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn api_error_message() {
let err = AgentError::Api("timeout".into());
assert_eq!(err.to_string(), "API 请求失败: timeout");
}
#[test]
fn context_error_message() {
let err = AgentError::Context("索引越界".into());
assert_eq!(err.to_string(), "上下文操作失败: 索引越界");
}
}