2016-12-30 02:16:04 +01:00
|
|
|
<?php
|
2015-08-07 01:59:25 +02:00
|
|
|
|
2016-08-23 23:47:40 +02:00
|
|
|
namespace Amp\Parallel\Sync\Internal;
|
2015-08-07 01:59:25 +02:00
|
|
|
|
2016-08-23 23:47:40 +02:00
|
|
|
use Amp\Parallel\PanicError;
|
2016-08-18 18:04:48 +02:00
|
|
|
|
2017-01-17 06:24:59 +01:00
|
|
|
class ExitFailure implements ExitResult {
|
2016-08-26 17:10:03 +02:00
|
|
|
/** @var string */
|
2015-08-07 01:59:25 +02:00
|
|
|
private $type;
|
|
|
|
|
2016-08-26 17:10:03 +02:00
|
|
|
/** @var string */
|
2015-08-07 01:59:25 +02:00
|
|
|
private $message;
|
|
|
|
|
2016-08-26 17:10:03 +02:00
|
|
|
/** @var int */
|
2015-08-07 01:59:25 +02:00
|
|
|
private $code;
|
|
|
|
|
2016-08-26 17:10:03 +02:00
|
|
|
/** @var array */
|
2015-08-07 01:59:25 +02:00
|
|
|
private $trace;
|
|
|
|
|
2016-08-18 18:04:48 +02:00
|
|
|
public function __construct(\Throwable $exception) {
|
2016-09-02 06:38:00 +02:00
|
|
|
$this->type = \get_class($exception);
|
2015-08-07 01:59:25 +02:00
|
|
|
$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-09-02 06:38:00 +02:00
|
|
|
$this->type,
|
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
|
|
|
|
);
|
|
|
|
}
|
2017-05-18 09:51:31 +02:00
|
|
|
}
|