diff --git a/query-grammar/src/infallible.rs b/query-grammar/src/infallible.rs index 21025f2f9..f059a1f62 100644 --- a/query-grammar/src/infallible.rs +++ b/query-grammar/src/infallible.rs @@ -1,7 +1,7 @@ //! nom combinators for infallible operations use std::convert::Infallible; - +use serde::Serialize; use nom::{AsChar, IResult, InputLength, InputTakeAtPosition}; pub(crate) type ErrorList = Vec; @@ -15,7 +15,7 @@ pub(crate) struct LenientErrorInternal { } /// A recoverable error and the position it happened at -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize)] pub struct LenientError { pub pos: usize, pub message: String, diff --git a/query-grammar/src/lib.rs b/query-grammar/src/lib.rs index 5658d5a7e..099b2b79d 100644 --- a/query-grammar/src/lib.rs +++ b/query-grammar/src/lib.rs @@ -47,5 +47,7 @@ mod tests { fn test_parse_query_lenient_wrong_query() { let (_, errors) = parse_query_lenient("title:"); assert!(errors.len() == 1); + let json = serde_json::to_string(&errors).unwrap(); + assert_eq!(json, r#"[{"pos":6,"message":"expected word"}]"#); } }