1//! Error types
23use thiserror::Error;
45pub type Result<T> = ::std::result::Result<T, Error>;
67#[derive(Debug, Error)]
8pub enum Error {
9#[cfg(feature = "typed")]
10 #[error("{}", _0)]
11TomlSerialize(#[from] ::toml::ser::Error),
1213#[cfg(feature = "typed")]
14 #[error("{}", _0)]
15TomlDeserialize(#[from] ::toml::de::Error),
1617// Errors for tokenizer
18#[error("Parsing the query '{0}' failed")]
19QueryParsingError(String),
2021#[error("The query on the TOML is empty")]
22EmptyQueryError,
2324#[error("The passed query has an empty identifier")]
25EmptyIdentifier,
2627#[error("The passed query tries to access an array but does not specify the index")]
28ArrayAccessWithoutIndex,
2930#[error("The passed query tries to access an array but does not specify a valid index")]
31ArrayAccessWithInvalidIndex,
3233// Errors for Resolver
34#[error("The identfier '{0}' is not present in the document")]
35IdentifierNotFoundInDocument(String),
3637#[error("Got an index query '[{0}]' but have table")]
38NoIndexInTable(usize),
3940#[error("Got an identifier query '{0}' but have array")]
41NoIdentifierInArray(String),
4243#[error("Got an identifier query '{0}' but have value")]
44QueryingValueAsTable(String),
4546#[error("Got an index query '{0}' but have value")]
47QueryingValueAsArray(usize),
4849#[error("Cannot delete table '{0:?}' which is not empty")]
50CannotDeleteNonEmptyTable(Option<String>),
5152#[error("Cannot delete array '{0:?}' which is not empty")]
53CannotDeleteNonEmptyArray(Option<String>),
5455#[error("Cannot access {0} because expected {1}")]
56CannotAccessBecauseTypeMismatch(&'static str, &'static str),
5758#[error("Cannot delete in array at {0}, array has length {1}")]
59ArrayIndexOutOfBounds(usize, usize),
6061#[error("Cannot access array at {0}, array has length {1}")]
62IndexOutOfBounds(usize, usize),
6364#[error("Type Error. Requested {0}, but got {1}")]
65TypeError(&'static str, &'static str),
6667#[error("Value at '{0}' not there")]
68NotAvailable(String),
69}