Codebase list php-react-promise / 68de9fe9-0808-44d5-a800-4e60c71caf16/main src / UnhandledRejectionException.php
68de9fe9-0808-44d5-a800-4e60c71caf16/main

Tree @68de9fe9-0808-44d5-a800-4e60c71caf16/main (Download .tar.gz)

UnhandledRejectionException.php @68de9fe9-0808-44d5-a800-4e60c71caf16/mainraw · history · blame

<?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;
    }
}