1use thiserror::Error as ThisError;
2use std::{result::Result as StdResult, num::ParseIntError};
3
4#[derive(Debug, ThisError)]
5pub enum Error {
6 #[error("Path index out of range when using wildcard. Index={idx};Length={len};")]
7 PathIndexOutOfRange { idx: usize, len: usize },
8 #[error("Match index out of range when using wildcard. Index={idx};Length={len};")]
9 MatchIndexOutOfRange { idx: usize, len: usize },
10 #[error("Unexpected end of right hand side expression.")]
11 UnexpectedEndOfRhs,
12 #[error("Unexpected right hand side expression.")]
13 UnexpectedRhsEntry,
14 #[error("Unexpected object in right hand side.")]
15 UnexpectedObjectInRhs,
16 #[error("Not implemented yet.")]
17 Todo,
18 #[error("Invalid index in expression: {raw}\n{source}")]
19 InvalidIndex {
20 raw: String,
21 #[source]
22 source: ParseIntError,
23 },
24 #[error("Array index out of range. Index={idx};Length={len};")]
25 ArrIndexOutOfRange { idx: usize, len: usize },
26 #[error("Json value can't be used as an index: {0:?}")]
27 InvalidIndexVal(serde_json::Value),
28 #[error("Key not found in object:{0}")]
29 KeyNotFound(String),
30 #[error("Expression didn't evaluate to a string.")]
31 EvalString,
32 #[error("Empty path while executing shift. THIS SHOULD NEVER HAPPEN.")]
33 ShiftEmptyPath,
34 #[error("Path is not empty after executing shift. THIS SHOULD NEVER HAPPEN.")]
35 ShiftPathNotEmpty,
36 #[error("Parse error: {0}")]
37 ParseError(String),
38 #[error("Invalid function: {0}")]
39 InvalidFunction(String),
40 #[error("Function argument error: {0}")]
41 FunctionArgumentError(String),
42 #[error("Path evaluation error: {0}")]
43 PathEvaluationError(String),
44}
45
46pub type Result<T> = StdResult<T, Error>;