apprentice_lib/
error.rs

1use thiserror::Error as ThisError;
2
3/// App errors.
4#[derive(ThisError, Debug)]
5pub enum Error {
6    /// Missing arguments.
7    #[error("Missing mandatory arguments: {0}\nTry `apprentice --help` for more information.")]
8    MissingArgError(&'static str),
9
10    /// LLM call error.
11    #[error("Failed to call LLM: {0}")]
12    LLMCallError(#[from] reqwest::Error),
13
14    /// LLM call error.
15    #[error("Failed to process LLM call: {0}")]
16    LLMJsonError(#[from] serde_json::Error),
17
18    /// LLM call error.
19    #[error("Failed to parse LLM response: {0}")]
20    LLMResponseError(&'static str),
21
22    /// General error.
23    #[error("{0}")]
24    Error(String),
25
26    /// LLM response error message.
27    #[error("LLM provider responded with error: {0}")]
28    LLMErrorMessage(String),
29
30    /// LLM response error message.
31    #[cfg(test)]
32    #[error("Test error: {0}")]
33    ForTests(&'static str),
34}