1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-30 04:39:01 +01:00
parallel/lib/Sync/Internal/ExitFailure.php
2016-08-23 16:47:40 -05:00

49 lines
981 B
PHP

<?php declare(strict_types = 1);
namespace Amp\Parallel\Sync\Internal;
use Amp\Parallel\PanicError;
class ExitFailure implements ExitStatus {
/**
* @var string
*/
private $type;
/**
* @var string
*/
private $message;
/**
* @var int
*/
private $code;
/**
* @var array
*/
private $trace;
public function __construct(\Throwable $exception) {
$this->type = get_class($exception);
$this->message = $exception->getMessage();
$this->code = $exception->getCode();
$this->trace = $exception->getTraceAsString();
}
/**
* {@inheritdoc}
*/
public function getResult() {
throw new PanicError(
\sprintf(
'Uncaught exception in execution context of type "%s" with message "%s"',
$this->type,
$this->message
),
$this->code,
$this->trace
);
}
}