You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
613 B
31 lines
613 B
<?php
|
|
|
|
namespace React\Promise;
|
|
|
|
class UnhandledRejectionException extends \RuntimeException
|
|
{
|
|
private $reason;
|
|
|
|
public static function resolve($reason)
|
|
{
|
|
if ($reason instanceof \Exception || $reason instanceof \Throwable) {
|
|
return $reason;
|
|
}
|
|
|
|
return new static($reason);
|
|
}
|
|
|
|
public function __construct($reason)
|
|
{
|
|
$this->reason = $reason;
|
|
|
|
$message = \sprintf('Unhandled Rejection: %s', \json_encode($reason));
|
|
|
|
parent::__construct($message, 0);
|
|
}
|
|
|
|
public function getReason()
|
|
{
|
|
return $this->reason;
|
|
}
|
|
}
|
|
|