package com.jy.framework.exception;

import cn.hutool.core.util.StrUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.Getter;
import lombok.NonNull;


/**
 * 自定义异常
 */
@Getter
public class ServiceException extends RuntimeException {

    private final Integer errorCode;

    /**
     * 传入业务异常说明
     */
    public ServiceException(@NonNull String errorMsg, Object... params) {
        super(StrUtil.format(errorMsg, params));
        this.errorCode = HttpServletResponse.SC_BAD_REQUEST;
    }

    /**
     * 传入业务异常说明
     */
    public ServiceException(@NonNull Integer errorCode, @NonNull String errorMsg, Object... params) {
        super(StrUtil.format(errorMsg, params));
        this.errorCode = errorCode;
    }

}
