@@ -58,19 +58,24 @@ pub (crate) fn compile<'i>(s: &'i str) -> Result<Query<'i>, QueryCompilationErro
5858 } ;
5959
6060 match ( positives, negatives) {
61- ( None , None ) => "error occured when parsing json path. " . to_string ( ) ,
62- ( Some ( p) , None ) => format ! ( "expected one of the following: {}. " , p) ,
63- ( None , Some ( n) ) => format ! ( "unexpected tokens found: {}. " , n) ,
64- ( Some ( p) , Some ( n) ) => format ! ( "expected one of the following: {}, unexpected tokens found: {}. " , p, n) ,
61+ ( None , None ) => "parsing error " . to_string ( ) ,
62+ ( Some ( p) , None ) => format ! ( "expected one of the following: {}" , p) ,
63+ ( None , Some ( n) ) => format ! ( "unexpected tokens found: {}" , n) ,
64+ ( Some ( p) , Some ( n) ) => format ! ( "expected one of the following: {}, unexpected tokens found: {}" , p, n) ,
6565 }
6666
6767 }
6868 pest:: error:: ErrorVariant :: CustomError { ref message } => message. clone ( ) ,
6969 } ;
7070
71+ let final_msg = if pos == s. len ( ) {
72+ format ! ( "\" {} <<<<----\" , {}." , s, msg)
73+ } else {
74+ format ! ( "\" {} ---->>>> {}\" , {}." , & s[ ..pos] , & s[ pos..] , msg)
75+ } ;
7176 Err ( QueryCompilationError {
7277 location : pos,
73- message : msg ,
78+ message : final_msg ,
7479 } )
7580 }
7681 }
0 commit comments