1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 17:52:14 +01:00
parallel/lib/Worker/Internal/TaskFailure.php
Aaron Piotrowski da84a772cf Port to Amp
2016-08-18 11:04:48 -05:00

45 lines
874 B
PHP

<?php
namespace Amp\Concurrent\Worker\Internal;
use Amp\Concurrent\TaskException;
class TaskFailure {
/**
* @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 getException() {
return new TaskException(
sprintf('Uncaught exception in worker of type "%s" with message "%s"', $this->type, $this->message),
$this->code,
$this->trace
);
}
}