2016-12-30 02:16:04 +01:00
|
|
|
<?php
|
2015-08-27 16:10:08 +02:00
|
|
|
|
2017-05-18 06:13:29 +02:00
|
|
|
namespace Amp\Parallel\Worker;
|
2016-08-18 18:04:48 +02:00
|
|
|
|
2020-02-11 18:06:30 +01:00
|
|
|
/**
|
|
|
|
* @deprecated TaskFailureException will be thrown from failed Tasks instead of this class.
|
|
|
|
*/
|
|
|
|
class TaskException extends \Exception
|
2018-10-07 16:50:45 +02:00
|
|
|
{
|
2016-08-30 20:19:10 +02:00
|
|
|
/** @var string Class name of exception thrown from task. */
|
|
|
|
private $name;
|
|
|
|
|
|
|
|
/** @var string Stack trace of the exception thrown from task. */
|
2015-08-27 16:10:08 +02:00
|
|
|
private $trace;
|
|
|
|
|
|
|
|
/**
|
2019-01-25 21:29:32 +01:00
|
|
|
* @param string $name The exception class name.
|
|
|
|
* @param string $message The panic message.
|
|
|
|
* @param string $trace The panic stack trace.
|
|
|
|
* @param \Throwable|null $previous Previous exception.
|
2015-08-27 16:10:08 +02:00
|
|
|
*/
|
2020-02-11 18:06:30 +01:00
|
|
|
public function __construct(string $name, string $message = '', string $trace = '', ?\Throwable $previous = null)
|
2018-10-07 16:50:45 +02:00
|
|
|
{
|
2019-01-25 21:29:32 +01:00
|
|
|
parent::__construct($message, 0, $previous);
|
2017-06-28 12:41:59 +02:00
|
|
|
|
2016-08-30 20:19:10 +02:00
|
|
|
$this->name = $name;
|
2015-08-27 16:10:08 +02:00
|
|
|
$this->trace = $trace;
|
|
|
|
}
|
2017-05-18 09:51:31 +02:00
|
|
|
|
2016-08-30 20:19:10 +02:00
|
|
|
/**
|
2020-02-11 18:06:30 +01:00
|
|
|
* @deprecated Use TaskFailureThrowable::getOriginalClassName() instead.
|
|
|
|
*
|
2016-08-30 20:19:10 +02:00
|
|
|
* Returns the class name of the exception thrown from the task.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-10-07 16:50:45 +02:00
|
|
|
public function getName(): string
|
|
|
|
{
|
2016-08-30 20:19:10 +02:00
|
|
|
return $this->name;
|
|
|
|
}
|
2017-05-18 09:51:31 +02:00
|
|
|
|
2015-08-27 16:10:08 +02:00
|
|
|
/**
|
2020-02-11 18:06:30 +01:00
|
|
|
* @deprecated Use TaskFailureThrowable::getOriginalTraceAsString() instead.
|
|
|
|
*
|
2016-08-30 20:19:10 +02:00
|
|
|
* Gets the stack trace at the point the exception was thrown in the task.
|
2015-08-27 16:10:08 +02:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-10-07 16:50:45 +02:00
|
|
|
public function getWorkerTrace(): string
|
|
|
|
{
|
2015-08-27 16:10:08 +02:00
|
|
|
return $this->trace;
|
|
|
|
}
|
|
|
|
}
|