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