| 1 |
<?php |
| 2 |
|
| 3 |
namespace Amp; |
| 4 |
|
| 5 |
class MultiReasonException extends \Exception |
| 6 |
{ |
| 7 |
/** @var \Throwable[] */ |
| 8 |
private $reasons; |
| 9 |
|
| 10 |
/** |
| 11 |
* @param \Throwable[] $reasons Array of exceptions rejecting the promise. |
| 12 |
* @param string|null $message |
| 13 |
*/ |
| 14 |
public function __construct(array $reasons, string $message = null) |
| 15 |
{ |
| 16 |
parent::__construct($message ?: "Multiple errors encountered; use " |
| 17 |
. self::class . "::getReasons() to retrieve the array of exceptions thrown"); |
| 18 |
|
| 19 |
$this->reasons = $reasons; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* @return \Throwable[] |
| 24 |
*/ |
| 25 |
public function getReasons(): array |
| 26 |
{ |
| 27 |
return $this->reasons; |
| 28 |
} |
| 29 |
} |
| 30 |
|