langchain_rust/chain/
error.rs

1use thiserror::Error;
2
3use crate::{language_models::LLMError, output_parsers::OutputParserError, prompt::PromptError};
4
5#[derive(Error, Debug)]
6pub enum ChainError {
7    #[error("LLM error: {0}")]
8    LLMError(#[from] LLMError),
9
10    #[error("Retriever error: {0}")]
11    RetrieverError(String),
12
13    #[error("OutputParser error: {0}")]
14    OutputParser(#[from] OutputParserError),
15
16    #[error("Prompt error: {0}")]
17    PromptError(#[from] PromptError),
18
19    #[error("Missing Object On Builder: {0}")]
20    MissingObject(String),
21
22    #[error("Missing input variable: {0}")]
23    MissingInputVariable(String),
24
25    #[error("Serde json error: {0}")]
26    SerdeJsonError(#[from] serde_json::Error),
27
28    #[error("Incorrect input variable: expected type {expected_type}, {source}")]
29    IncorrectInputVariable {
30        source: serde_json::Error,
31        expected_type: String,
32    },
33
34    #[error("Error: {0}")]
35    OtherError(String),
36
37    #[error("Database error: {0}")]
38    DatabaseError(String),
39
40    #[error("Agent error: {0}")]
41    AgentError(String),
42}