function * genThrow() {
    yield 'egg';
    throw new Error('I am out of eggs');
}

try {
    const eggy = genThrow();
    eggy.next();
    // second call invokes throw
    eggy.next();
} catch (e) {
    console.log(e); // Error: I am out of eggs
}