<commit_before>package io.github.ihongs;

/**
 * 异常本地化工具
 * @author Hongs
 */
public final class HongsCurse {

    private final       int code;
    private final    String desc;
    private final Throwable that;

    private String   lang;
    private String   term;
    private String[] opts;

    HongsCurse( int errno, String error, Throwable cause ) {
        this.code = errno;
        this.desc = error;
        this.that = cause;
    }

    /**
     * 获取代号
     * @return
     */
    public int getErrno() {
        return this.code;
    }

    /**
     * 获取描述
     * @return
     */
    public String getError() {
        return this.desc;
    }

    /**
     * 接口状态
     * @return
     */
    public int getState() {
        if ( 600 > code ) {
            return code ;
        }
        String     codx = "Ex"+ Integer.toString(code, 16 );
        CoreConfig conf = CoreConfig.getInstance("defects");
        if (null!= lang ) {
            conf = conf.clone();
            conf . load( lang );
        }
        return conf.getProperty(codx, code);
    }

    /**
     * 接口代码
     * @return
     */
    public String getStage() {
        if (code >= 600 ) {
            return "Ex" + Integer.toString(code, 16);
        } else
        if (code >= 400 ) {
            return "Er" + Integer.toString(code, 10);
        }

        String codx;
        if (lang != null
        && !lang.isEmpty()
        && !lang.equals("default")
        && !lang.equals("defects")) {
            codx  = lang.replace( '/','.')
                        .replace('\\','.')
                  + ":";
        } else {
            codx  = "" ;
        }
        if (term != null) {
            codx += term;
        } else
        if (desc != null) {
            codx += desc;
        }
        return codx;
    }

    /**
     * 描述文本
     * @return
     */
    @Override
    public String toString()
    {
        return  getMessage();
    }<commit_msg>接口异常代码统一在异常类中处理<commit_after>package io.github.ihongs;

/**
 * 异常本地化工具
 * @author Hongs
 */
public final class HongsCurse {

    private final       int code;
    private final    String desc;
    private final Throwable that;

    private String   lang;
    private String   term;
    private String[] opts;

    HongsCurse( int errno, String error, Throwable cause ) {
        this.code = errno;
        this.desc = error;
        this.that = cause;
    }

    /**
     * 获取代号
     * @return
     */
    public int getErrno() {
        return this.code;
    }

    /**
     * 获取描述
     * @return
     */
    public String getError() {
        return this.desc;
    }

    /**
     * 接口状态
     * @return
     */
    public int getState() {
        if ( 600 > code ) {
            return code ;
        }
        String     codx = "Ex"+ Integer.toString(code, 16 );
        CoreConfig conf = CoreConfig.getInstance("defects");
        if (null!= lang ) {
            conf = conf.clone();
            conf . load( lang );
        }
        return conf.getProperty(codx, code);
    }

    /**
     * 接口代码
     * @return
     */
    public String getStage() {
        if (code >= 600 ) {
            return "Ex" + Integer.toString(code, 16);
        } else
        if (code >= 400 ) {
            return "Er" + Integer.toString(code, 10);
        }

        String codx;
        if (term != null
        && !term.isEmpty()) {
            codx  = term;
        } else
        if (desc != null
        && !desc.isEmpty()) {
            codx  = desc;
        } else
        {
            codx  = "error";
        }

        // 增加模块前缀
        if (lang != null
        && !lang.isEmpty()
        && !lang.equals("default")
        && !lang.equals("defects")) {
            String coda;
            coda  = lang.replace('/' , '.')
                        .replace('\\', '.')
                  +  ".";
            if (codx.startsWith(coda) == false) {
                codx  =  coda + codx;
            }
        }

        return  codx  ;
    }

    /**
     * 描述文本
     * @return
     */
    @Override
    public String toString()
    {
        return  getMessage();
    }
{'fraction_non_alphanumeric': 0.1313032886723508, 'fraction_numerical': 0.007308160779537149, 'mean_word_length': 1.2449425915800985, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 9, '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': '1690027', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1296, 'n_words': 292}