serde_select/
error.rs

1/// Error types
2
3use thiserror::Error;
4
5pub type Result<T> = ::std::result::Result<T, Error>;
6
7#[derive(Debug, Error)]
8pub enum Error {
9    #[error("Serialization error")]
10    Serialize(/*#[from] Box<::serde::ser::Error>*/),
11
12    #[error("Deserialization error")]
13    Deserialize(/*#[from] Box<::serde::de::Error>*/),
14
15    // Errors for tokenizer
16    #[error("Parsing the query '{}' failed", _0)]
17    QueryParsingError(String),
18
19    #[error("The query on the document is empty")]
20    EmptyQueryError,
21
22    #[error("The passed query has an empty identifier")]
23    EmptyIdentifier,
24
25    #[error("The passed query tries to access an array but does not specify the index")]
26    ArrayAccessWithoutIndex,
27
28    #[error("The passed query tries to access an array but does not specify a valid index")]
29    ArrayAccessWithInvalidIndex,
30
31    // Errors for Resolver
32    #[error("The identfier '{}' is not present in the document", _0)]
33    IdentifierNotFoundInDocument(String),
34
35    #[error("Got an index query '[{}]' but have table", _0)]
36    NoIndexInTable(usize),
37
38    #[error("Got an identifier query '{}' but have array", _0)]
39    NoIdentifierInArray(String),
40
41    #[error("Got an identifier query '{}' but have value", _0)]
42    QueryingValueAsTable(String),
43
44    #[error("Got an index query '{}' but have value", _0)]
45    QueryingValueAsArray(usize),
46
47    #[error("Cannot delete table '{:?}' which is not empty", _0)]
48    CannotDeleteNonEmptyTable(Option<String>),
49
50    #[error("Cannot delete array '{:?}' which is not empty", _0)]
51    CannotDeleteNonEmptyArray(Option<String>),
52
53    #[error("Cannot access {} because expected {}", _0, _1)]
54    CannotAccessBecauseTypeMismatch(&'static str, &'static str),
55
56    #[error("Cannot delete in array at {}, array has length {}", _0, _1)]
57    ArrayIndexOutOfBounds(usize, usize),
58
59    #[error("Cannot access array at {}, array has length {}", _0, _1)]
60    IndexOutOfBounds(usize, usize),
61
62    #[error("Type Error. Requested {}, but got {}", _0, _1)]
63    TypeError(&'static str, &'static str),
64
65    #[error("Value at '{}' not there", _0)]
66    NotAvailable(String),
67}