From 7407397ef2b80cf8028cb802375b34243592c081 Mon Sep 17 00:00:00 2001 From: Paul Colomiets Date: Fri, 27 Apr 2018 17:13:13 +0300 Subject: [PATCH] Better error reporting on invalid query It still panics, but previous error was: ``` thread 'main' panicked at 'Box', src/lib.rs:190:23 note: Run with `RUST_BACKTRACE=1` for a backtrace. ``` Now it looks like: ``` hread 'main' panicked at 'Bad query: query parse error: Parse error at 1:2 Unexpected `}[Punctuator]` Expected `Name` or `...` ', src/lib.rs:190:23 note: Run with `RUST_BACKTRACE=1` for a backtrace. ``` --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f9d6852..5cf9bab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -187,7 +187,7 @@ mod filters { pub fn filter_stream<'de, R>(query: String, reader: R, func: fn(Value)) where R: Read<'de> { // Parse query string to AST match parse_query(&query) { - Err(error) => panic!(error), + Err(error) => panic!("Bad query: {}", error), Ok(ast) => { // Convert AST to selection tree let selection = filters::get_selection(ast);