stent
stent copied to clipboard
Catch async errors in nested generators
Hi,
The use of the yield* keyword allows us to delegate operations to nested generators. By creating a new generator using yield* and a try/catch block, we can catch async errors in nested generators.
I removed the try/catch block around the inside call of handleGenerator because:
-
errors happening in nested generators are now caught in the new
nestedGenerator -
other errors happening in
handleGeneratorare caught in the function itself -
it makes the code redundant to have a
try/catchblock two times.
I also added tests for various scenarios.
Solves #56