Skip to main content

langchain_rust/chain/
error.rs

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