Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch async errors in nested generators #55

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

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