use thiserror::Error;
pub type Result<T> = ::std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("Serialization error")]
Serialize(),
#[error("Deserialization error")]
Deserialize(),
#[error("Parsing the query '{}' failed", _0)]
QueryParsingError(String),
#[error("The query on the document is empty")]
EmptyQueryError,
#[error("The passed query has an empty identifier")]
EmptyIdentifier,
#[error("The passed query tries to access an array but does not specify the index")]
ArrayAccessWithoutIndex,
#[error("The passed query tries to access an array but does not specify a valid index")]
ArrayAccessWithInvalidIndex,
#[error("The identfier '{}' is not present in the document", _0)]
IdentifierNotFoundInDocument(String),
#[error("Got an index query '[{}]' but have table", _0)]
NoIndexInTable(usize),
#[error("Got an identifier query '{}' but have array", _0)]
NoIdentifierInArray(String),
#[error("Got an identifier query '{}' but have value", _0)]
QueryingValueAsTable(String),
#[error("Got an index query '{}' but have value", _0)]
QueryingValueAsArray(usize),
#[error("Cannot delete table '{:?}' which is not empty", _0)]
CannotDeleteNonEmptyTable(Option<String>),
#[error("Cannot delete array '{:?}' which is not empty", _0)]
CannotDeleteNonEmptyArray(Option<String>),
#[error("Cannot access {} because expected {}", _0, _1)]
CannotAccessBecauseTypeMismatch(&'static str, &'static str),
#[error("Cannot delete in array at {}, array has length {}", _0, _1)]
ArrayIndexOutOfBounds(usize, usize),
#[error("Cannot access array at {}, array has length {}", _0, _1)]
IndexOutOfBounds(usize, usize),
#[error("Type Error. Requested {}, but got {}", _0, _1)]
TypeError(&'static str, &'static str),
#[error("Value at '{}' not there", _0)]
NotAvailable(String),
}