Skip to content

Commit

Permalink
Prevent silencing ExitFailure in ProcessContext->join() (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi authored Dec 21, 2024
1 parent 9777db1 commit 5113111
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Context/ProcessContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,16 @@ public function join(?Cancellation $cancellation = null): mixed
$data = $this->receiveExitResult($cancellation);

$code = $this->process->join();
if ($code !== 0) {
throw new ContextException(\sprintf("Context exited with code %d", $code));
}

return $data->getResult();
try {
return $data->getResult();
} finally {
if ($code !== 0) {
// If an ExitFailure throws above, the exception will be automatically attached as the previous
// exception on the instance thrown below.
throw new ContextException(\sprintf("Context exited with code %d", $code));
}
}
}

/**
Expand Down

0 comments on commit 5113111

Please sign in to comment.