maxdemarzi/neography — pull request #172 by jayniz (2014-05-15 13:27:08+00:00)
Title: Fix: NotFoundException being thrown instead of a ParameterNotFoundException

The regexp for a `NotFoundException` was also matching `ParameterNotFoundException`s. This PR fixes that. While investigating, I found some weird behaviour I don't quite understand though. Let me know if I should repost the following as a neo4j issue, or if I'm just doing it wrong ;-)

The neo4j responses when a parameter of a cypher query is missing are a little confusing. In all of the three following cases I would expect a `ParameterNotFoundException`, but neo4j is behaving differently for each query.

Let's take a query that uses `ORDER BY` but with a parameter missing:
```shell
curl -XPOST -d'{"query":"MATCH n WHERE n.foo={missing_param} RETURN n ORDER BY n.bar","params":{}}' -H'Content-Type:application/json' -H'Accept:application/json;xxstream=true;charset=UTF-8' http://localhost:7474/db/data/cypher
```

Throws a `ParameterNotFoundException` as expected.

Now, if we take the same query but leave out the `ORDER BY` clause, we get a `BadInputException`:

```shell
curl -XPOST -d'{"query":"MATCH n WHERE n.foo={missing_param} RETURN n","params":{}}' -H'Content-Type:application/json' -H'Accept:application/json;xxstream=true;charset=UTF-8' http://localhost:7474/db/data/cypher
```

If, however, we express the query differently:

```shell
curl -XPOST -d'{"query":"MATCH (n:Foo{bar:{missing_param}}) RETURN n ORDER BY n.bar","params":{}}' -H'Content-Type:application/json' -H'Accept:application/json;xxstream=true;charset=UTF-8' http://localhost:7474/db/data/cypher
```
we just get an empty result set with _no exception_.