Phase 1 FHIR on PHP- Provider Client and implement classes. (#1422)
[openemr.git] / phpfhir / vendor / guzzlehttp / promises / src / RejectionException.php
blob07c1136da166075fb7354548306b5755be8ceab2
1 <?php
2 namespace GuzzleHttp\Promise;
4 /**
5 * A special exception that is thrown when waiting on a rejected promise.
7 * The reason value is available via the getReason() method.
8 */
9 class RejectionException extends \RuntimeException
11 /** @var mixed Rejection reason. */
12 private $reason;
14 /**
15 * @param mixed $reason Rejection reason.
16 * @param string $description Optional description
18 public function __construct($reason, $description = null)
20 $this->reason = $reason;
22 $message = 'The promise was rejected';
24 if ($description) {
25 $message .= ' with reason: ' . $description;
26 } elseif (is_string($reason)
27 || (is_object($reason) && method_exists($reason, '__toString'))
28 ) {
29 $message .= ' with reason: ' . $this->reason;
30 } elseif ($reason instanceof \JsonSerializable) {
31 $message .= ' with reason: '
32 . json_encode($this->reason, JSON_PRETTY_PRINT);
35 parent::__construct($message);
38 /**
39 * Returns the rejection reason.
41 * @return mixed
43 public function getReason()
45 return $this->reason;