<commit_before><commit_msg>Store panic info inside an error<commit_after><?php
namespace Icicle\Concurrent\Exception;

class PanicError extends Error
{
    /**
     * @var array Stack trace of the panic.
     */
    private $panicTrace;

    /**
     * Creates a new panic error.
     *
     * @param string $message The panic message.
     * @param int    $code    The panic code.
     * @param array  $trace   The panic stack trace.
     */
    public function __construct($message = '', $code = 0, array $trace = [])
    {
        parent::__construct($message, $code);
        $this->panicTrace = $trace;
    }

    /**
     * Gets the stack trace at the point the panic occurred.
     *
     * @return array
     */
    public function getPanicTrace()
    {
        return $this->panicTrace;
    }

    /**
     * Gets the panic stack trace as a string.
     *
     * @return string
     */
    public function getPanicTraceAsString()
    {
        foreach ($this->panicTrace as $id => $scope) {
            $string .= sprintf("%d# %s(%d): %s%s%s()\n",
                $id,
                $scope['file'],
                $scope['line'],
                isset($scope['class']) ? $scope['class'] : '',
                isset($scope['type']) ? $scope['type'] : '',
                $scope['function']);
        }

        return $string;
    }
}
{'fraction_non_alphanumeric': 0.14349442379182156, 'fraction_numerical': 0.0007434944237918215, 'mean_word_length': 1.821802935010482, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3923674', 'n_tokens_mistral': 394, 'n_tokens_neox': 384, 'n_words': 105}