ruvector_collections/
error.rs1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, CollectionError>;
7
8#[derive(Debug, Error)]
10pub enum CollectionError {
11 #[error("Collection not found: {name}")]
13 CollectionNotFound {
14 name: String,
16 },
17
18 #[error("Collection already exists: {name}")]
20 CollectionAlreadyExists {
21 name: String,
23 },
24
25 #[error("Alias not found: {alias}")]
27 AliasNotFound {
28 alias: String,
30 },
31
32 #[error("Alias already exists: {alias}")]
34 AliasAlreadyExists {
35 alias: String,
37 },
38
39 #[error("Invalid configuration: {message}")]
41 InvalidConfiguration {
42 message: String,
44 },
45
46 #[error("Alias '{alias}' points to non-existent collection '{collection}'")]
48 InvalidAlias {
49 alias: String,
51 collection: String,
53 },
54
55 #[error("Cannot delete collection '{collection}' because it has active aliases: {aliases:?}")]
57 CollectionHasAliases {
58 collection: String,
60 aliases: Vec<String>,
62 },
63
64 #[error("Invalid collection name: {name} - {reason}")]
66 InvalidName {
67 name: String,
69 reason: String,
71 },
72
73 #[error("Database error: {0}")]
75 DatabaseError(#[from] ruvector_core::error::RuvectorError),
76
77 #[error("IO error: {0}")]
79 IoError(#[from] std::io::Error),
80
81 #[error("Serialization error: {0}")]
83 SerializationError(String),
84}
85
86impl From<serde_json::Error> for CollectionError {
87 fn from(err: serde_json::Error) -> Self {
88 CollectionError::SerializationError(err.to_string())
89 }
90}
91
92impl From<bincode::error::EncodeError> for CollectionError {
93 fn from(err: bincode::error::EncodeError) -> Self {
94 CollectionError::SerializationError(err.to_string())
95 }
96}
97
98impl From<bincode::error::DecodeError> for CollectionError {
99 fn from(err: bincode::error::DecodeError) -> Self {
100 CollectionError::SerializationError(err.to_string())
101 }
102}