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