langchain_rust/text_splitter/
error.rs

1use text_splitter::ChunkConfigError;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum TextSplitterError {
6    #[error("Empty input text")]
7    EmptyInputText,
8
9    #[error("Mismatch metadata and text")]
10    MetadataTextMismatch,
11
12    #[error("Tokenizer not found")]
13    TokenizerNotFound,
14
15    #[error("Tokenizer creation failed due to invalid tokenizer")]
16    InvalidTokenizer,
17
18    #[error("Tokenizer creation failed due to invalid model")]
19    InvalidModel,
20
21    #[error("Invalid chunk overlap and size")]
22    InvalidSplitterOptions,
23
24    #[error("Error: {0}")]
25    OtherError(String),
26}
27
28impl From<ChunkConfigError> for TextSplitterError {
29    fn from(_: ChunkConfigError) -> Self {
30        Self::InvalidSplitterOptions
31    }
32}