matrix_sdk_search/
error.rs1use tantivy::{
16 directory::error::OpenDirectoryError as TantivyOpenDirectoryError,
17 query::QueryParserError as TantivyQueryParserError,
18};
19use thiserror::Error;
20
21#[derive(Error, Debug)]
23pub enum IndexError {
24 #[error(transparent)]
26 TantivyError(tantivy::TantivyError),
27
28 #[error(transparent)]
30 OpenDirectoryError(TantivyOpenDirectoryError),
31
32 #[error(transparent)]
34 QueryParserError(TantivyQueryParserError),
35
36 #[error(transparent)]
38 IndexSchemaError(IndexSchemaError),
39
40 #[error(transparent)]
42 IndexWriteError(IndexWriteError),
43
44 #[error(transparent)]
46 IndexSearchError(IndexSearchError),
47
48 #[error("Failed to add event to index")]
50 EventNotAdded,
51
52 #[error("Message type not supported")]
54 MessageTypeNotSupported,
55
56 #[error("Cannot index redacted message")]
58 CannotIndexRedactedMessage,
59
60 #[error("Cannot index empty message")]
62 EmptyMessage,
63
64 #[error(transparent)]
66 IO(std::io::Error),
67}
68
69impl From<tantivy::TantivyError> for IndexError {
70 fn from(err: tantivy::TantivyError) -> IndexError {
71 IndexError::TantivyError(err)
72 }
73}
74
75impl From<TantivyOpenDirectoryError> for IndexError {
76 fn from(err: TantivyOpenDirectoryError) -> IndexError {
77 IndexError::OpenDirectoryError(err)
78 }
79}
80
81impl From<TantivyQueryParserError> for IndexError {
82 fn from(err: TantivyQueryParserError) -> IndexError {
83 IndexError::QueryParserError(err)
84 }
85}
86
87impl From<IndexSchemaError> for IndexError {
88 fn from(err: IndexSchemaError) -> IndexError {
89 IndexError::IndexSchemaError(err)
90 }
91}
92
93impl From<IndexWriteError> for IndexError {
94 fn from(err: IndexWriteError) -> IndexError {
95 IndexError::IndexWriteError(err)
96 }
97}
98
99impl From<IndexSearchError> for IndexError {
100 fn from(err: IndexSearchError) -> IndexError {
101 IndexError::IndexSearchError(err)
102 }
103}
104
105impl From<std::io::Error> for IndexError {
106 fn from(err: std::io::Error) -> IndexError {
107 IndexError::IO(err)
108 }
109}
110
111#[derive(Error, Debug)]
113pub enum IndexSchemaError {
114 #[error(transparent)]
116 TantivyError(tantivy::TantivyError),
117}
118
119impl From<tantivy::TantivyError> for IndexSchemaError {
120 fn from(err: tantivy::TantivyError) -> IndexSchemaError {
121 IndexSchemaError::TantivyError(err)
122 }
123}
124
125#[derive(Error, Debug)]
127pub enum IndexWriteError {
128 #[error(transparent)]
130 TantivyError(tantivy::TantivyError),
131}
132
133impl From<tantivy::TantivyError> for IndexWriteError {
134 fn from(err: tantivy::TantivyError) -> IndexWriteError {
135 IndexWriteError::TantivyError(err)
136 }
137}
138
139#[derive(Error, Debug)]
141pub enum IndexSearchError {
142 #[error(transparent)]
144 TantivyError(tantivy::TantivyError),
145}
146
147impl From<tantivy::TantivyError> for IndexSearchError {
148 fn from(err: tantivy::TantivyError) -> IndexSearchError {
149 IndexSearchError::TantivyError(err)
150 }
151}