catch query errors