Handle errors while iterating over records.