improve error reporting on invalid query