<commit_before><?php
/**
 * This file is part of the Ray.Di package.
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace Ray\Di\Exception;

use Ray\Di\Exception;

class Unbound extends \LogicException implements ExceptionInterface
{
    public function __toString()
    {
        $messages = [sprintf("- %s\n", $this->getMessage())];
        $e = $this->getPrevious();

        return $this->buildMessage($e, $messages) . "\n" . $e->getTraceAsString();
    }

    /**
     * @param Unbound $e
     * @param array   $msg
     *
     * @return string
     */
    private function buildMessage(Unbound $e, array $msg)
    {
        while ($e instanceof Unbound) {
            $msg[] = sprintf("- %s\n", $e->getMessage());
            $lastE = $e;
            $e = $e->getPrevious();
        }<commit_msg>fix error handling when no trace given<commit_after><?php
/**
 * This file is part of the Ray.Di package.
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace Ray\Di\Exception;

use Ray\Di\Exception;

class Unbound extends \LogicException implements ExceptionInterface
{
    public function __toString()
    {
        $messages = [sprintf("- %s\n", $this->getMessage())];
        $e = $this->getPrevious();
        if (! $e instanceof \Exception) {
            return $this->getMainMessage($this);
        }

        return $this->buildMessage($e, $messages) . "\n" . $e->getTraceAsString();
    }

    /**
     * @param Unbound $e
     * @param array   $msg
     *
     * @return string
     */
    private function buildMessage(Unbound $e, array $msg)
    {
        while ($e instanceof Unbound) {
            $msg[] = sprintf("- %s\n", $e->getMessage());
            $lastE = $e;
            $e = $e->getPrevious();
        }
{'fraction_non_alphanumeric': 0.16022727272727272, 'fraction_numerical': 0.0, 'mean_word_length': 2.2371323529411766, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '6242540', 'n_tokens_mistral': 533, 'n_tokens_neox': 541, 'n_words': 136}