improved query error messages