-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom error with variants to
parser
module (#50)
* Add custom error with variants to `parser` module * Replace `unwrap_or` with proper Result handling * Fix clippy warning Closes #38
- Loading branch information
1 parent
413b811
commit 2cfb303
Showing
4 changed files
with
191 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use pest::iterators::Pairs; | ||
use thiserror::Error; | ||
|
||
use super::parser::Rule; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum JsonPathParserError<'a> { | ||
#[error("Failed to parse rule: {0}")] | ||
PestError(#[from] pest::error::Error<Rule>), | ||
#[error("Failed to parse JSON: {0}")] | ||
JsonParsingError(#[from] serde_json::Error), | ||
#[error("{0}")] | ||
ParserError(String), | ||
#[error("Unexpected rule {0:?} when trying to parse logic atom: {1:?}")] | ||
UnexpectedRuleLogicError(Rule, Pairs<'a, Rule>), | ||
#[error("Unexpected `none` when trying to parse logic atom: {0:?}")] | ||
UnexpectedNoneLogicError(Pairs<'a, Rule>), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
//! The parser for the jsonpath. | ||
//! The module grammar denotes the structure of the parsing grammar | ||
pub mod errors; | ||
mod macros; | ||
pub mod model; | ||
#[allow(clippy::module_inception)] | ||
#[allow(clippy::result_large_err)] | ||
pub mod parser; |
Oops, something went wrong.