handle stopiteration exception while paginating a generator resource