1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 17:09:40 +01:00
amp/lib/MultiReasonException.php

30 lines
670 B
PHP
Raw Normal View History

<?php
2016-08-16 06:46:26 +02:00
2016-05-24 17:39:19 +02:00
namespace Amp;
2016-05-21 16:44:52 +02:00
2018-06-18 20:00:01 +02:00
class MultiReasonException extends \Exception
{
2016-08-18 05:25:54 +02:00
/** @var \Throwable[] */
2016-05-21 16:44:52 +02:00
private $reasons;
/**
2016-11-14 20:59:21 +01:00
* @param \Throwable[] $reasons Array of exceptions rejecting the promise.
* @param string|null $message
2016-05-21 16:44:52 +02:00
*/
2018-06-18 20:00:01 +02:00
public function __construct(array $reasons, string $message = null)
{
parent::__construct($message ?: "Multiple errors encountered; use "
. self::class . "::getReasons() to retrieve the array of exceptions thrown");
2016-05-21 16:44:52 +02:00
$this->reasons = $reasons;
}
/**
2016-08-11 21:35:58 +02:00
* @return \Throwable[]
2016-05-21 16:44:52 +02:00
*/
2018-06-18 20:00:01 +02:00
public function getReasons(): array
{
2016-05-21 16:44:52 +02:00
return $this->reasons;
}
}