1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-03 18:17:52 +01:00
parallel/lib/Worker/Internal/TaskFailure.php

45 lines
874 B
PHP
Raw Normal View History

2015-08-27 16:10:08 +02:00
<?php
2016-08-18 18:04:48 +02:00
namespace Amp\Concurrent\Worker\Internal;
2015-08-27 16:10:08 +02:00
2016-08-18 18:04:48 +02:00
use Amp\Concurrent\TaskException;
class TaskFailure {
2015-08-27 16:10:08 +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-27 16:10:08 +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 getException() {
2015-09-11 19:39:51 +02:00
return new TaskException(
2015-08-27 16:10:08 +02:00
sprintf('Uncaught exception in worker of type "%s" with message "%s"', $this->type, $this->message),
$this->code,
$this->trace
);
}
}