package com.sckw.core.exception;



import com.alibaba.fastjson2.annotation.JSONType;
import com.sckw.core.common.enums.enums.ErrorCodeEnum;
import lombok.Data;

/**
 * @Author: donglang
 * @CreateTime: 2025-10-09
 * @Description: 异常
 * @Version: 1.0
 */
@JSONType(includes = {"errorCode", "errorMsg", "message"})
@Data
public class BusinessPlatfromException extends RuntimeException {

    /** 编码 */
    private String errorCode;


    /** 描述 */
    private String errorMsg;


    public BusinessPlatfromException() {
        super();
    }


    /**
     * 构造函数
     * @param errorCodeEnum 错误码
     * @param errorMsg 具体错误信息
     */
    public BusinessPlatfromException(ErrorCodeEnum errorCodeEnum, String errorMsg) {
        super(errorMsg = errorMsg == null ? errorCodeEnum.getDesc() : errorMsg);
        this.errorCode = errorCodeEnum.getCode();
        this.errorMsg = errorMsg;
    }

    /**
     * 构造函数
     * @param errorCodeEnum 错误码
     * @param errorMsg 具体错误信息
     * @param cause 异常
     */
    public BusinessPlatfromException(ErrorCodeEnum errorCodeEnum, String errorMsg, Throwable cause) {
        super(errorMsg = errorMsg == null ? errorCodeEnum.getDesc() : errorMsg, cause);
        this.errorCode = errorCodeEnum.getCode();
        this.errorMsg = errorMsg;
    }
}
