PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.5.3
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.5.3
3.7.2 3.7.1 3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 All 73 releases
stockpack / vendor / guzzlehttp / promises / src / RejectionException.php

RejectionException.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.5.3, at vendor/guzzlehttp/promises/src/RejectionException.php

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp\Promise;
3
4 /**
5 * A special exception that is thrown when waiting on a rejected promise.
6 *
7 * The reason value is available via the getReason() method.
8 */
9 class RejectionException extends \RuntimeException
10 {
11 /** @var mixed Rejection reason. */
12 private $reason;
13
14 /**
15 * @param mixed $reason Rejection reason.
16 * @param string $description Optional description
17 */
18 public function __construct($reason, $description = null)
19 {
20 $this->reason = $reason;
21
22 $message = 'The promise was rejected';
23
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);
33 }
34
35 parent::__construct($message);
36 }
37
38 /**
39 * Returns the rejection reason.
40 *
41 * @return mixed
42 */
43 public function getReason()
44 {
45 return $this->reason;
46 }
47 }
48