Skip to content

Catch async errors in nested generators#55

Open
SofianeDjellouli wants to merge 8 commits intokrasimir:masterfrom
SofianeDjellouli:catch-async-calls-in-nested-generators
Open

Catch async errors in nested generators#55
SofianeDjellouli wants to merge 8 commits intokrasimir:masterfrom
SofianeDjellouli:catch-async-calls-in-nested-generators

Conversation

@SofianeDjellouli
Copy link
Contributor

@SofianeDjellouli SofianeDjellouli commented Aug 24, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant