Skip to content

PHP 5.5 generator exception #242

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

Closed
wants to merge 6 commits into from
Closed

PHP 5.5 generator exception #242

wants to merge 6 commits into from

Conversation

bzick
Copy link

@bzick bzick commented Dec 18, 2012

Allows you to throw an exception into the yield of the generator.
Example:

function reader() {
   $b = 5;
   try {
       $a = (yield $b);
   } catch(Exception $e) {
       var_dump("Stop generator");
   }
}


$reader = reader();
$reader->raise(new Exception("Invalid data"));

@bzick
Copy link
Author

bzick commented Dec 18, 2012

Oh, i forgot to fix tests

@lstrojny
Copy link
Contributor

@nikic, the original author of generators already added support for Generator::throw(). You should coordinate your efforts.

@lstrojny
Copy link
Contributor

Forgot to add his branch: https://github.com/nikic/php-src/tree/addGeneratorThrow

@bzick bzick closed this Dec 19, 2012
@bzick
Copy link
Author

bzick commented Dec 19, 2012

Ok, thanks

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.

2 participants