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

Commit

Permalink
Merge pull request #14 from php-http/promise-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Dec 15, 2015
2 parents 12945dd + cd2935a commit fd6971a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Guzzle6Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,15 @@ public function __construct(PromiseInterface $promise, RequestInterface $request
if ($reason instanceof HttplugException) {
$this->state = self::REJECTED;
$this->exception = $reason;

throw $this->exception;
}

if (!($reason instanceof GuzzleExceptions\GuzzleException)) {
throw new \RuntimeException('Invalid reason');
} elseif ($reason instanceof GuzzleExceptions\GuzzleException) {
$this->state = self::REJECTED;
$this->exception = $this->handleException($reason, $request);
} elseif($reason instanceof \Exception) {
throw new \RuntimeException('Invalid exception returned from Guzzle6', 0, $reason);
} else {
throw new \UnexpectedValueException('Reason returned from Guzzle6 must be an Exception', 0, $reason);
}

$this->state = self::REJECTED;
$this->exception = $this->handleException($reason, $request);

throw $this->exception;
});
}
Expand Down

0 comments on commit fd6971a

Please sign in to comment.