package cn.iocoder.yudao.framework.common.exception;

import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import lombok.Getter;

/**
 * 基于错误代码的异常。
 * @author Administrator
 */
public class CodeException extends RuntimeException {
    private static final long serialVersionUID = -3135542583325079803L;

    /**
     * 异常代码。
     */
    @Getter
    private final String code;

    @Getter
    private String msg;

    public CodeException(String code) {
        super(code);
        this.code = code;
    }

    public CodeException(String code, String msg) {
        super(code);
        this.msg = msg;
        this.code = code;
    }

    public CodeException(String code, Throwable throwable) {
        super(code, throwable);
        this.code = code;
    }

    public String getMsg() {
        return I18nMessage.getMessage(msg);
    }
}
