Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Commit fd6971a

Browse files
committed
Merge pull request #14 from php-http/promise-exception
2 parents 12945dd + cd2935a commit fd6971a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/Guzzle6Promise.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,15 @@ public function __construct(PromiseInterface $promise, RequestInterface $request
5858
if ($reason instanceof HttplugException) {
5959
$this->state = self::REJECTED;
6060
$this->exception = $reason;
61-
62-
throw $this->exception;
63-
}
64-
65-
if (!($reason instanceof GuzzleExceptions\GuzzleException)) {
66-
throw new \RuntimeException('Invalid reason');
61+
} elseif ($reason instanceof GuzzleExceptions\GuzzleException) {
62+
$this->state = self::REJECTED;
63+
$this->exception = $this->handleException($reason, $request);
64+
} elseif($reason instanceof \Exception) {
65+
throw new \RuntimeException('Invalid exception returned from Guzzle6', 0, $reason);
66+
} else {
67+
throw new \UnexpectedValueException('Reason returned from Guzzle6 must be an Exception', 0, $reason);
6768
}
6869

69-
$this->state = self::REJECTED;
70-
$this->exception = $this->handleException($reason, $request);
71-
7270
throw $this->exception;
7371
});
7472
}

0 commit comments

Comments
 (0)