package com.jeequan.jeepay.core.exception;

import com.jeequan.jeepay.core.model.openapi.AccessError;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * 一般异常信息的异常，全局捕获会抛出异常信息给前端
 * @author Djh
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AccessMsgException extends RuntimeException {

    private final Serializable obj;

    private final String code;

    public AccessMsgException(AccessError error) {
        this(error.getCode(),error.getMsg(),null);
    }

    public AccessMsgException(String code, String msg) {
        this(code,msg,null);
    }

    public AccessMsgException(String code, String msg, Serializable obj) {
        super(msg);
        this.code = code;
        this.obj = obj;
    }

}

