1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 17:52:14 +01:00
parallel/lib/Sync/ExitFailure.php
Aaron Piotrowski b654463339
Fix code style
2018-10-07 09:50:45 -05:00

44 lines
907 B
PHP

<?php
namespace Amp\Parallel\Sync;
class ExitFailure implements ExitResult
{
/** @var string */
private $type;
/** @var string */
private $message;
/** @var int|string */
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(
$this->type,
\sprintf(
'Uncaught %s in execution context with message "%s" and code "%s"',
$this->type,
$this->message,
$this->code
),
$this->trace
);
}
}