private function getFrames(Throwable $exception): array
    {
        $frames = $this->getTrace($exception);

        // Fill empty line/file info for call_user_func_array usages (PHP Bug #44428)
        foreach ($frames as $k => $frame) {
            if (empty($frame['file'])) {
                // Default values when file and line are missing
                $file      = '[internal]';
                $line      = 0;
                $nextFrame = \count($frames[$k + 1]) !== 0 ? $frames[$k + 1] : [];

                if ($this->isValidNextFrame($nextFrame)) {
                    $file = $nextFrame['file'];
                    $line = $nextFrame['line'];
                }

                $frames[$k]['file'] = $file;
                $frames[$k]['line'] = $line;
            }

            $frames['function'] = $frame['function'] ?? '';
        }

        // Find latest non-error handling frame index ($i) used to remove error handling frames
        $i = 0;

        foreach ($frames as $k => $frame) {
            if (isset($frame['file'], $frame['line']) &&
                $frame['file'] === $exception->getFile() &&
                $frame['line'] === $exception->getLine()
            ) {
                $i = $k;
            }
        }

        // Remove error handling frames
        if ($i > 0) {
            \array_splice($frames, 0, $i);
        }

        \array_unshift($frames, $this->getFrameFromException($exception));

        // show the last 5 frames
        return \array_slice($frames, 0, 5);
    }