1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 09:37:57 +01:00
parallel/lib/Sync/PanicError.php
Aaron Piotrowski 1ee8e202ed
Apply the same treatment to context exceptions
Sends info about previous exceptions thrown in the context to the parent.
2019-01-25 17:53:19 -06:00

49 lines
1.1 KiB
PHP

<?php
namespace Amp\Parallel\Sync;
final class PanicError extends \Error
{
/** @var string Class name of uncaught exception. */
private $name;
/** @var string Stack trace of the panic. */
private $trace;
/**
* Creates a new panic error.
*
* @param string $name The uncaught exception class.
* @param string $message The panic message.
* @param string $trace The panic stack trace.
* @param \Throwable|null $previous Previous exception.
*/
public function __construct(string $name, string $message = '', string $trace = '', \Throwable $previous = null)
{
parent::__construct($message, 0, $previous);
$this->name = $name;
$this->trace = $trace;
}
/**
* Returns the class name of the uncaught exception.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* Gets the stack trace at the point the panic occurred.
*
* @return string
*/
public function getPanicTrace(): string
{
return $this->trace;
}
}