1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-11 08:39:48 +01:00
parallel/lib/Sync/ExitFailure.php
Aaron Piotrowski 26e826a05f
Add code to exception message, addresses #21
Code is no longer passed to exception constructor in parent context.
2017-11-10 11:32:15 -06:00

43 lines
949 B
PHP

<?php
namespace Amp\Parallel\Sync;
use Amp\Parallel\PanicError;
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 exception in execution context of type "%s" with message "%s" and code "%s"',
$this->type,
$this->message,
$this->code
),
$this->trace
);
}
}