#[derive(Debug)]
pub enum TestError {
Io(std::io::Error),
Setup(String),
ToolCall(ToolCallError),
Ollama(String),
Timeout(String),
}
#[derive(Debug)]
pub struct ToolCallError {
pub tool: Option<String>,
pub args: Option<String>,
pub code: i32,
}
impl std::fmt::Display for TestError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TestError::Io(e) => write!(f, "I/O error: {}", e),
TestError::Setup(e) => write!(f, "Setup error: {}", e),
TestError::ToolCall(e) => write!(f, "Tool call error: {:?}", e),
TestError::Ollama(e) => write!(f, "Ollama error: {}", e),
TestError::Timeout(e) => write!(f, "Timeout: {}", e),
}
}
}
impl std::error::Error for TestError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
TestError::Io(e) => Some(e),
_ => None,
}
}
}
impl From<std::io::Error> for TestError {
fn from(e: std::io::Error) -> Self {
TestError::Io(e)
}
}
pub type TestsResult<T> = std::result::Result<T, TestError>;