<commit_before><?php
/**
 * Created by PhpStorm.
 * User: janhuang
 * Date: 15/6/24
 * Time: 上午11:54
 * Github: https://www.github.com/janhuang
 * Coding: https://www.coding.net/janhuang
 * SegmentFault: http://segmentfault.com/u/janhuang
 * Blog: http://segmentfault.com/blog/janhuang
 * Gmail: <EMAIL>
 * WebSite: http://www.janhuang.me
 */

namespace FastD\Debug;

use FastD\Debug\Exceptions\BaseException;

class ErrorHandler
{
    public function handle($code, $message, $file, $line)
    {
        throw new BaseException($message, $code);
    }

    public function handleFatalError(array $error = null)
    {

    }

    public static function registerHandle()
    {
        $handle = new static();

        set_error_handler([$handle, 'handle']);

        register_shutdown_function([$handle, 'handleFatalError']);

        return $handle;
    }
}<commit_msg>fix error code offset bug<commit_after><?php
/**
 * Created by PhpStorm.
 * User: janhuang
 * Date: 15/6/24
 * Time: 上午11:54
 * Github: https://www.github.com/janhuang
 * Coding: https://www.coding.net/janhuang
 * SegmentFault: http://segmentfault.com/u/janhuang
 * Blog: http://segmentfault.com/blog/janhuang
 * Gmail: <EMAIL>
 * WebSite: http://www.janhuang.me
 */

namespace FastD\Debug;

use FastD\Debug\Exceptions\BaseException;

class ErrorHandler
{
    public function handle($code, $message, $file, $line)
    {
        if (array_key_exists($code, Debug::$statusTexts)) {
            $code = 500;
        }
        
        throw new BaseException($message, $code);
    }

    public function handleFatalError(array $error = null)
    {

    }

    public static function registerHandle()
    {
        $handle = new static();

        set_error_handler([$handle, 'handle']);

        register_shutdown_function([$handle, 'handleFatalError']);

        return $handle;
    }
}
{'fraction_non_alphanumeric': 0.14146868250539957, 'fraction_numerical': 0.011339092872570195, 'mean_word_length': 3.0108225108225106, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, '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': '797525', 'n_tokens_mistral': 637, 'n_tokens_neox': 605, 'n_words': 121}