stent icon indicating copy to clipboard operation
stent copied to clipboard

Catch async errors in nested generators

Open SofianeDjellouli opened this issue 5 years ago • 0 comments

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 handleGenerator are caught in the function itself

  • it makes the code redundant to have a try/catch block two times.

I also added tests for various scenarios.

Solves #56

SofianeDjellouli avatar Aug 24 '20 05:08 SofianeDjellouli