package net.geedge.common;

import lombok.Data;

/**
 * 自定义异常
 */
@Data
public class APIException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private String msg;
    private int code = RCode.ERROR.getCode();
    private Object[] param = new Object[]{};
    private RCode rCode;

    public APIException(RCode rCode) {
        super(rCode.getMsg());
        this.code = rCode.getCode();
        this.msg = rCode.getMsg();
        this.param = rCode.getParam();
        this.rCode = rCode;
    }

    public APIException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public APIException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

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

    public APIException(String msg, int code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }
}