swiftide_core/chat_completion/
errors.rs

1use thiserror::Error;
2
3use crate::CommandError;
4
5#[derive(Error, Debug)]
6pub enum ToolError {
7    /// I.e. the llm calls the tool with the wrong arguments
8    #[error("arguments for tool failed to parse: {0:#}")]
9    WrongArguments(#[from] serde_json::Error),
10
11    /// Tool requires arguments but none were provided
12    #[error("arguments missing for tool {0:#}")]
13    MissingArguments(String),
14
15    /// Tool execution failed
16    #[error("tool execution failed: {0:#}")]
17    ExecutionFailed(#[from] CommandError),
18
19    #[error(transparent)]
20    Unknown(#[from] anyhow::Error),
21}
22
23#[derive(Error, Debug)]
24pub enum ChatCompletionError {
25    /// Underlying errors by the llm
26    #[error("llm returned an error: {0}")]
27    LLM(Box<dyn std::error::Error + Send + Sync>),
28
29    #[error(transparent)]
30    Unknown(#[from] anyhow::Error),
31}