Fixing error reporting for invalid queries.