type = \get_class($exception); $this->message = $exception->getMessage(); $this->code = $exception->getCode(); $this->trace = flattenThrowableBacktrace($exception); if ($previous = $exception->getPrevious()) { $this->previous = new self($previous); } } /** * {@inheritdoc} */ public function getResult() { throw $this->createException(); } private function createException(): ContextPanicError { $previous = $this->previous ? $this->previous->createException() : null; return new ContextPanicError($this->type, $this->message, $this->code, $this->trace, $previous); } }