(PHP 5 >= 5.5.0, PHP 7, PHP 8)
Generator::throw — Throw an exception into the generator
public Generator::throw ( Throwable $exception ) : mixed
Throws an exception into the generator and resumes execution of the generator. The behavior will be the same as if the current yield expression was replaced with a throw $exception
statement.
If the generator is already closed when this method is invoked, the exception will be thrown in the caller's context instead.
exception
Exception to throw into the generator.
Returns the yielded value.
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/generator.throw.php