weaviate_community/collections/
error.rs

1/// All custom errors
2use std::{
3    error::Error,
4    fmt::{Display, Formatter, Result},
5};
6
7/// Custom QueryError, used when there was a mismatch in expected query parameters for endpoints.
8#[derive(Debug)]
9pub struct QueryError(pub String);
10
11impl Error for QueryError {}
12
13impl Display for QueryError {
14    fn fmt(&self, f: &mut Formatter) -> Result {
15        write!(f, "Invalid query parameters passed: {}", self.0)
16    }
17}
18
19/// Custom NotConfiguredError, used when trying to retrieve about a configuration that is not
20/// active.
21#[derive(Debug)]
22pub struct NotConfiguredError(pub String);
23impl Error for NotConfiguredError {}
24
25impl Display for NotConfiguredError {
26    fn fmt(&self, f: &mut Formatter) -> Result {
27        write!(f, "NotConfiguredError: {}", self.0)
28    }
29}
30
31/// Custom BatchError, used when the request to a batch endpoint results in a statuscode that isn't
32/// 200.
33#[derive(Debug)]
34pub struct BatchError(pub String);
35impl Error for BatchError {}
36
37impl Display for BatchError {
38    fn fmt(&self, f: &mut Formatter) -> Result {
39        write!(f, "BatchError: {}", self.0)
40    }
41}
42
43/// Custom SchemaError, used when the request to a schema endpoint results in a statuscode that
44/// isn't 200.
45#[derive(Debug)]
46pub struct SchemaError(pub String);
47impl Error for SchemaError {}
48
49impl Display for SchemaError {
50    fn fmt(&self, f: &mut Formatter) -> Result {
51        write!(f, "SchemaError: {}", self.0)
52    }
53}
54
55/// Custom BackupError, used when the request to a schema endpoint results in a statuscode that
56/// isn't 200.
57#[derive(Debug)]
58pub struct BackupError(pub String);
59impl Error for BackupError {}
60
61impl Display for BackupError {
62    fn fmt(&self, f: &mut Formatter) -> Result {
63        write!(f, "BackupError: {}", self.0)
64    }
65}
66
67/// Custom GraphQLError, used when there was a mismatch in expected query parameters for endpoints.
68#[derive(Debug)]
69pub struct GraphQLError(pub String);
70
71impl Error for GraphQLError {}
72
73impl Display for GraphQLError {
74    fn fmt(&self, f: &mut Formatter) -> Result {
75        write!(f, "Error executing GraphQL query: {}", self.0)
76    }
77}
78
79/// Custom NodesError, used when there was an incorrect status code for the nodes endpoint.
80#[derive(Debug)]
81pub struct NodesError(pub String);
82
83impl Error for NodesError {}
84
85impl Display for NodesError {
86    fn fmt(&self, f: &mut Formatter) -> Result {
87        write!(f, "NodesError: {}", self.0)
88    }
89}
90
91/// Custom ClassificationError, used when there was an incorrect status code for the
92/// classification endpoint.
93#[derive(Debug)]
94pub struct ClassificationError(pub String);
95
96impl Error for ClassificationError {}
97
98impl Display for ClassificationError {
99    fn fmt(&self, f: &mut Formatter) -> Result {
100        write!(f, "ClassificationErEror: {}", self.0)
101    }
102}
103
104/// Custom ModuleError, used when there was an incorrect status code for the
105/// modules endpoint.
106#[derive(Debug)]
107pub struct ModuleError(pub String);
108
109impl Error for ModuleError {}
110
111impl Display for ModuleError {
112    fn fmt(&self, f: &mut Formatter) -> Result {
113        write!(f, "ModuleErEror: {}", self.0)
114    }
115}