def iter_errback(iterable, errback, *a, **kw):
    """Wraps an iterable calling an errback if an error is caught while
    iterating it.
    """
    it = iter(iterable)
    while True:
        try:
            yield next(it)
        except StopIteration:
            break
        except Exception:
            errback(failure.Failure(), *a, **kw)
Wraps an iterable calling an errback if an error is caught while
    iterating it.
    
stackoverflow/venv/lib/python3.6/site-packages/scrapy/utils/defer.py