If there is compilation error in the query string then exception is always thrown with default msg, ideally it should be the error msg from the parser. Since its always "Bad JSONPath query" its hard to debug the issue. Some thing similar to this as in case of failure a Failure object is returned.
def query(q: String, js: JsValue): JsValue = {
val tokens = parser.compile(q)
if (!tokens.successful) {
error(Some(tokens.toString()))
} else {
parse(tokens.get, js)
}
}