DEV Community

Discussion on: What the... generators!

Collapse
 
genta profile image
Fabio Russo

You can use the .throw() method by calling the generator.

Make It an instanceof Error.
If there’s s an error the generator will stop the execution, by propagating the call to the next .throw() method.