Introspecting why a Neo4J query failed

We have a use case where we need to see what part of a query didn't find any results. An example could be

MATCH (c:Car) WHERE c.id = "foo"
MATCH (p:Person) WHERE p.id = "bar"
MATCH (p)-[:OWNS]->(c)
RETURN *

This query can fail either because no car was found, no person was found or because no relationship was found. Is there a way to run the query where it will report what part wasn't found?

You could use optional match, so a null is returned instead of no results.

OPTIONAL MATCH (c:Car) WHERE c.id = "foo"
OPTIONAL MATCH (p:Person) WHERE p.id = "bar"
OPTIONAL MATCH (p)-[r:OWNS]->(c)
RETURN *