diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/error.rs b/src/error.rs index eb9d161..82eff3d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,69 +1,67 @@ /// Error types +use thiserror::Error; + pub type Result<T> = ::std::result::Result<T, Error>; -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum Error { - #[cfg(feature = "typed")] - #[fail(display = "{}", _0)] - Serialize(#[cause] ::serde::ser::Error), + #[error("Serialization error")] + Serialize(/*#[from] Box<::serde::ser::Error>*/), - #[cfg(feature = "typed")] - #[fail(display = "{}", _0)] - Deserialize(#[cause] ::serde::de::Error), + #[error("Deserialization error")] + Deserialize(/*#[from] Box<::serde::de::Error>*/), // Errors for tokenizer - #[fail(display = "Parsing the query '{}' failed", _0)] + #[error("Parsing the query '{}' failed", _0)] QueryParsingError(String), - #[fail(display = "The query on the document is empty")] + #[error("The query on the document is empty")] EmptyQueryError, - #[fail(display = "The passed query has an empty identifier")] + #[error("The passed query has an empty identifier")] EmptyIdentifier, - #[fail(display = "The passed query tries to access an array but does not specify the index")] + #[error("The passed query tries to access an array but does not specify the index")] ArrayAccessWithoutIndex, - #[fail( - display = "The passed query tries to access an array but does not specify a valid index" - )] + #[error("The passed query tries to access an array but does not specify a valid index")] ArrayAccessWithInvalidIndex, // Errors for Resolver - #[fail(display = "The identfier '{}' is not present in the document", _0)] + #[error("The identfier '{}' is not present in the document", _0)] IdentifierNotFoundInDocument(String), - #[fail(display = "Got an index query '[{}]' but have table", _0)] + #[error("Got an index query '[{}]' but have table", _0)] NoIndexInTable(usize), - #[fail(display = "Got an identifier query '{}' but have array", _0)] + #[error("Got an identifier query '{}' but have array", _0)] NoIdentifierInArray(String), - #[fail(display = "Got an identifier query '{}' but have value", _0)] + #[error("Got an identifier query '{}' but have value", _0)] QueryingValueAsTable(String), - #[fail(display = "Got an index query '{}' but have value", _0)] + #[error("Got an index query '{}' but have value", _0)] QueryingValueAsArray(usize), - #[fail(display = "Cannot delete table '{:?}' which is not empty", _0)] + #[error("Cannot delete table '{:?}' which is not empty", _0)] CannotDeleteNonEmptyTable(Option<String>), - #[fail(display = "Cannot delete array '{:?}' which is not empty", _0)] + #[error("Cannot delete array '{:?}' which is not empty", _0)] CannotDeleteNonEmptyArray(Option<String>), - #[fail(display = "Cannot access {} because expected {}", _0, _1)] + #[error("Cannot access {} because expected {}", _0, _1)] CannotAccessBecauseTypeMismatch(&'static str, &'static str), - #[fail(display = "Cannot delete in array at {}, array has length {}", _0, _1)] + #[error("Cannot delete in array at {}, array has length {}", _0, _1)] ArrayIndexOutOfBounds(usize, usize), - #[fail(display = "Cannot access array at {}, array has length {}", _0, _1)] + #[error("Cannot access array at {}, array has length {}", _0, _1)] IndexOutOfBounds(usize, usize), - #[fail(display = "Type Error. Requested {}, but got {}", _0, _1)] + #[error("Type Error. Requested {}, but got {}", _0, _1)] TypeError(&'static str, &'static str), - #[fail(display = "Value at '{}' not there", _0)] + #[error("Value at '{}' not there", _0)] NotAvailable(String), } |