1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-13 09:37:26 +01:00
parallel/lib/Sync/Internal/ExitFailure.php

49 lines
985 B
PHP
Raw Normal View History

2016-08-22 06:40:48 +02:00
<?php declare(strict_types = 1);
2015-08-07 01:59:25 +02:00
2016-08-18 18:04:48 +02:00
namespace Amp\Concurrent\Sync\Internal;
2015-08-07 01:59:25 +02:00
2016-08-18 18:04:48 +02:00
use Amp\Concurrent\PanicError;
class ExitFailure implements ExitStatus {
2015-08-07 01:59:25 +02:00
/**
* @var string
*/
private $type;
/**
* @var string
*/
private $message;
/**
* @var int
*/
private $code;
/**
* @var array
*/
private $trace;
2016-08-18 18:04:48 +02:00
public function __construct(\Throwable $exception) {
2015-08-07 01:59:25 +02:00
$this->type = get_class($exception);
$this->message = $exception->getMessage();
$this->code = $exception->getCode();
$this->trace = $exception->getTraceAsString();
}
/**
* {@inheritdoc}
*/
2016-08-18 18:04:48 +02:00
public function getResult() {
2015-08-07 01:59:25 +02:00
throw new PanicError(
2016-08-18 18:04:48 +02:00
\sprintf(
2015-08-27 16:10:08 +02:00
'Uncaught exception in execution context of type "%s" with message "%s"',
$this->type,
$this->message
),
2015-08-07 01:59:25 +02:00
$this->code,
$this->trace
);
}
}