jsonpath_rust/parser/
errors.rs

1use thiserror::Error;
2
3use super::parser::Rule;
4
5#[derive(Error, Debug)]
6pub enum JsonPathParserError {
7    #[error("Failed to parse rule: {0}")]
8    PestError(#[from] Box<pest::error::Error<Rule>>),
9    #[error("Unexpected rule {0:?} when trying to parse logic atom: {1} within {2}")]
10    UnexpectedRuleLogicError(Rule, String, String),
11    #[error("Unexpected `none` when trying to parse logic atom: {0} within {1}")]
12    UnexpectedNoneLogicError(String, String),
13    #[error("Pest returned successful parsing but did not produce any output, that should be unreachable due to .pest definition file: SOI ~ chain ~ EOI")]
14    UnexpectedPestOutput,
15    #[error("expected a `Rule::path` but found nothing")]
16    NoRulePath,
17    #[error("expected a `JsonPath::Descent` but found nothing")]
18    NoJsonPathDescent,
19    #[error("expected a `JsonPath::Field` but found nothing")]
20    NoJsonPathField,
21    #[error("expected a `f64` or `i64`, but got {0}")]
22    InvalidNumber(String),
23    #[error("Invalid toplevel rule for JsonPath: {0:?}")]
24    InvalidTopLevelRule(Rule),
25    #[error("Failed to get inner pairs for {0}")]
26    EmptyInner(String),
27    #[error("Invalid json path: {0}")]
28    InvalidJsonPath(String),
29}