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)]
9pub enum ChainError {
10    #[error("LLM error: {0}")]
11    LLMError(#[from] LLMError),
12
13    #[error("Retriever error: {0}")]
14    RetrieverError(String),
15
16    #[error("OutputParser error: {0}")]
17    OutputParser(#[from] OutputParserError),
18
19    #[error("Prompt error: {0}")]
20    PromptError(#[from] PromptError),
21
22    #[error("Missing Object On Builder: {0}")]
23    MissingObject(String),
24
25    #[error("Missing input variable: {0}")]
26    MissingInputVariable(String),
27
28    #[error("Serde json error: {0}")]
29    SerdeJsonError(#[from] serde_json::Error),
30
31    #[error("Incorrect input variable: expected type {expected_type}, {source}")]
32    IncorrectInputVariable {
33        source: serde_json::Error,
34        expected_type: String,
35    },
36
37    #[error("Error: {0}")]
38    OtherError(String),
39
40    #[error("Database error: {0}")]
41    DatabaseError(String),
42
43    #[error("Agent error: {0}")]
44    AgentError(String),
45
46    #[error("Memory error: {0}")]
47    MemoryError(#[from] MemoryError),
48}