1use thiserror::Error;
23use super::parser::Rule;
45#[derive(Error, Debug)]
6pub enum JsonPathParserError {
7#[error("Failed to parse rule: {0}")]
8PestError(#[from] Box<pest::error::Error<Rule>>),
9#[error("Unexpected rule {0:?} when trying to parse logic atom: {1} within {2}")]
10UnexpectedRuleLogicError(Rule, String, String),
11#[error("Unexpected `none` when trying to parse logic atom: {0} within {1}")]
12UnexpectedNoneLogicError(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")]
14UnexpectedPestOutput,
15#[error("expected a `Rule::path` but found nothing")]
16NoRulePath,
17#[error("expected a `JsonPath::Descent` but found nothing")]
18NoJsonPathDescent,
19#[error("expected a `JsonPath::Field` but found nothing")]
20NoJsonPathField,
21#[error("expected a `f64` or `i64`, but got {0}")]
22InvalidNumber(String),
23#[error("Invalid toplevel rule for JsonPath: {0:?}")]
24InvalidTopLevelRule(Rule),
25#[error("Failed to get inner pairs for {0}")]
26EmptyInner(String),
27#[error("Invalid json path: {0}")]
28InvalidJsonPath(String),
29}