From f602f04e92a307859e8e344e1cca10e3e2a51613 Mon Sep 17 00:00:00 2001 From: Kalle Stenflo Date: Thu, 12 Nov 2015 21:55:34 +0100 Subject: [PATCH] Handle exceptions when parsing Filter. --- .../jayway/jsonpath/internal/filter/FilterCompiler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java index c6a97f97..ff6fdb54 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java @@ -40,8 +40,12 @@ public class FilterCompiler { private CharacterIndex filter; public static Filter compile(String filterString) { - FilterCompiler compiler = new FilterCompiler(filterString); - return new CompiledFilter(compiler.compile()); + try { + FilterCompiler compiler = new FilterCompiler(filterString); + return new CompiledFilter(compiler.compile()); + } catch (Exception e){ + throw new InvalidPathException("Could not compile inline filter : " + filterString, e); + } } private FilterCompiler(String filterString) {