mirror of
https://github.com/danog/parallel.git
synced 2024-11-26 20:34:40 +01:00
Catch StreamExceptions thrown when reading
try/catch should have been around call to read().
This commit is contained in:
parent
582578c092
commit
cb15de11ff
@ -58,15 +58,17 @@ class ChannelledStream implements Channel {
|
||||
public function receive(): Promise {
|
||||
return call(function () {
|
||||
while ($this->received->isEmpty()) {
|
||||
if (($chunk = yield $this->read->read()) === null) {
|
||||
throw new ChannelException("The channel closed. Did the context die?");
|
||||
}
|
||||
|
||||
try {
|
||||
$this->parser->push($chunk);
|
||||
$chunk = yield $this->read->read();
|
||||
} catch (StreamException $exception) {
|
||||
throw new ChannelException("Reading from the channel failed. Did the context die?", $exception);
|
||||
}
|
||||
|
||||
if ($chunk === null) {
|
||||
throw new ChannelException("The channel closed unexpectedly. Did the context die?");
|
||||
}
|
||||
|
||||
$this->parser->push($chunk);
|
||||
}
|
||||
|
||||
return $this->received->shift();
|
||||
|
Loading…
Reference in New Issue
Block a user