# File lib/mongo/collection/view/change_stream.rb, line 154
        def try_next
          raise StopIteration.new if closed?
          retried = false

          begin
            doc = @cursor.try_next
          rescue Mongo::Error => e
            unless e.change_stream_resumable?
              raise
            end

            if retried
              # Rerun initial aggregation.
              # Any errors here will stop iteration and break out of this
              # method
              close
              create_cursor!
              retried = false
              doc = @cursor.try_next
            else
              # Attempt to retry a getMore once
              retried = true
              retry
            end
          end

          if doc
            cache_resume_token(doc)
          end
          doc
        end