package cn.axzo.msg.center.common.exception;

import cn.axzo.msg.center.common.enums.InternalErrorCodeEnum;

/**
 * 服务异常
 *
 * @author xiajiafu
 * @since 2022/6/11
 */
public class ServiceException extends RuntimeException {

    private final Integer errorCode;
    private Object dataObject;

    public ServiceException(String msg) {
        this(9998, msg);
    }

    public ServiceException(Integer code, String msg) {
        super(msg);
        this.errorCode = code;
    }

    public ServiceException(Integer code, String msg, Object data) {
        super(msg);
        this.errorCode = code;
        this.dataObject = data;
    }

    public ServiceException(InternalErrorCodeEnum code, String msg, Object data) {
        this(code.getInsideCode(), msg, data);
    }

    public Integer getErrorCode() {
        return this.errorCode;
    }

    public ServiceException() {
        super();
        this.errorCode = 9998;
    }

    public ServiceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.errorCode = 9998;
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
        this.errorCode = 9998;
    }

    public ServiceException(Throwable cause) {
        super(cause);
        this.errorCode = 9998;
    }
}
