<commit_before><?php
class Kwf_Exception_NotFound extends Kwf_Exception_Abstract
{
    public function getHeader()
    {
        return 'HTTP/1.1 404 Not Found';
    }

    public function getTemplate()
    {
        return 'Error404';
    }

    public function log()
    {
        $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '(none)';
        $ignore = array(
            '/favicon.ico',
            '/robots.txt',
        );
        if (in_array($requestUri, $ignore)) {
            return false;
        }

        $body = '';
        $body .= $this->_format('REQUEST_URI', isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '(none)');
        $body .= $this->_format('HTTP_REFERER', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '(none)');
        $body .= $this->_format('Time', date('H:i:s'));

        $path = 'log/notfound/' . date('Y-m-d');

        $filename = date('H_i_s') . '_' . uniqid() . '.txt';

        return $this->_writeLog($path, $filename, $body);
    }

    public function render($ignoreCli = false)
    {
        if (isset($_SERVER['REQUEST_URI']) && Kwf_Registry::get('db')) {
            $target = Kwf_Model_Abstract::getInstance('Kwf_Util_Model_Redirects')
                ->findRedirectUrl('path', $_SERVER['REQUEST_URI']);
            if ($target) {
                header('Location: '.$target, true, 301);
                exit;
            }
        }
        parent::render($ignoreCli);
    }
}
<commit_msg>avoid throwing an exception when handling exception<commit_after><?php
class Kwf_Exception_NotFound extends Kwf_Exception_Abstract
{
    public function getHeader()
    {
        return 'HTTP/1.1 404 Not Found';
    }

    public function getTemplate()
    {
        return 'Error404';
    }

    public function log()
    {
        $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '(none)';
        $ignore = array(
            '/favicon.ico',
            '/robots.txt',
        );
        if (in_array($requestUri, $ignore)) {
            return false;
        }

        $body = '';
        $body .= $this->_format('REQUEST_URI', isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '(none)');
        $body .= $this->_format('HTTP_REFERER', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '(none)');
        $body .= $this->_format('Time', date('H:i:s'));

        $path = 'log/notfound/' . date('Y-m-d');

        $filename = date('H_i_s') . '_' . uniqid() . '.txt';

        return $this->_writeLog($path, $filename, $body);
    }

    public function render($ignoreCli = false)
    {
        try {
            if (isset($_SERVER['REQUEST_URI']) && Kwf_Registry::get('db')) {
                $target = Kwf_Model_Abstract::getInstance('Kwf_Util_Model_Redirects')
                    ->findRedirectUrl('path', $_SERVER['REQUEST_URI']);
                if ($target) {
                    header('Location: '.$target, true, 301);
                    exit;
                }
            }
            parent::render($ignoreCli);
        } catch (Exception $e) {
            Kwf_Debug::handleException($e);
        }
    }
}

{'fraction_non_alphanumeric': 0.1724137931034483, 'fraction_numerical': 0.006959822840873141, 'mean_word_length': 2.181086519114688, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '783226', 'n_tokens_mistral': 993, 'n_tokens_neox': 943, 'n_words': 167}