1#[derive(Debug)]
5pub enum TestError {
6 Io(std::io::Error),
8 Setup(String),
10 ToolCall(ToolCallError),
12 Ollama(String),
14 Timeout(String),
16}
17
18#[derive(Debug)]
20pub struct ToolCallError {
21 pub tool: Option<String>,
23 pub args: Option<String>,
25 pub code: i32,
27}
28
29impl std::fmt::Display for TestError {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 match self {
33 TestError::Io(e) => write!(f, "I/O error: {}", e),
34 TestError::Setup(e) => write!(f, "Setup error: {}", e),
35 TestError::ToolCall(e) => write!(f, "Tool call error: {:?}", e),
36 TestError::Ollama(e) => write!(f, "Ollama error: {}", e),
37 TestError::Timeout(e) => write!(f, "Timeout: {}", e),
38 }
39 }
40}
41
42impl std::error::Error for TestError {
44 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
45 match self {
46 TestError::Io(e) => Some(e),
47 _ => None,
48 }
49 }
50}
51
52impl From<std::io::Error> for TestError {
54 fn from(e: std::io::Error) -> Self {
55 TestError::Io(e)
56 }
57}
58
59pub type TestsResult<T> = std::result::Result<T, TestError>;