mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-06-17 10:01:29 +00:00
improve error message
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
|
||||
use array_tool::vec::{Intersect, Union};
|
||||
use indexmap::IndexMap;
|
||||
@ -514,7 +515,6 @@ enum FilterKey {
|
||||
All,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum JsonPathError {
|
||||
EmptyPath,
|
||||
EmptyValue,
|
||||
@ -522,6 +522,23 @@ pub enum JsonPathError {
|
||||
Serde(String),
|
||||
}
|
||||
|
||||
impl fmt::Debug for JsonPathError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for JsonPathError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
JsonPathError::EmptyPath => f.write_str("path not set"),
|
||||
JsonPathError::EmptyValue => f.write_str("json value not set"),
|
||||
JsonPathError::Path(msg) => f.write_str(&format!("path error: \n{}\n", msg)),
|
||||
JsonPathError::Serde(msg) => f.write_str(&format!("serde error: \n{}\n", msg)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Selector<'a, 'b> {
|
||||
node: Option<Node>,
|
||||
|
Reference in New Issue
Block a user