Skip to content

Commit 55bdbe7

Browse files
committed
Fix #27: ErrorPlugin and sendAsyncRequest() incompatibility
1 parent 70f02e0 commit 55bdbe7

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
### Fixed
6+
7+
- #27: ErrorPlugin and sendAsyncRequest() incompatibility
8+
9+
310
## 1.6 - 2016-09-12
411

512
### Changed

src/MultiRunner.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,7 @@ public function wait(PromiseCore $targetCore = null)
9393
}
9494

9595
if (CURLE_OK === $info['result']) {
96-
try {
97-
$core->fulfill();
98-
} catch (\Exception $e) {
99-
$core->reject(
100-
new RequestException($e->getMessage(), $core->getRequest(), $e)
101-
);
102-
}
96+
$core->fulfill();
10397
} else {
10498
$error = curl_error($core->getHandle());
10599
$core->reject(new RequestException($error, $core->getRequest()));

src/PromiseCore.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,19 @@ public function getException()
177177

178178
/**
179179
* Fulfill promise.
180-
*
181-
* @throws \Exception from on fulfill handler.
182180
*/
183181
public function fulfill()
184182
{
185183
$this->state = Promise::FULFILLED;
186184
$response = $this->responseBuilder->getResponse();
187-
$response->getBody()->seek(0);
185+
try {
186+
$response->getBody()->seek(0);
187+
} catch (\RuntimeException $e) {
188+
$exception = new Exception\TransferException($e->getMessage(), $e->getCode(), $e);
189+
$this->reject($exception);
190+
191+
return;
192+
}
188193

189194
while (count($this->onFulfilled) > 0) {
190195
$callback = array_shift($this->onFulfilled);

0 commit comments

Comments
 (0)