package cc.niushuai.bastionserver.common.exception; import cc.niushuai.bastionserver.common.constant.CommonConstant; import cn.hutool.core.util.StrUtil; import lombok.Data; import lombok.EqualsAndHashCode; /** * Business自定义异常 * * @author: niushuai233 */ @Data @EqualsAndHashCode(callSuper = false) public class BusinessException extends RuntimeException { private static final long serialVersionUID = 1L; private int code; private String message; private Object[] params; public BusinessException(String message) { super(message); } public BusinessException(Throwable cause) { super(cause); } public BusinessException(int code, String message) { this.code = code; this.message = message; } public BusinessException(String message, Object... params) { super(message); this.code = CommonConstant.INTERNAL_SERVER_ERROR_500; this.params = params; this.message = StrUtil.format(message, params); } public BusinessException(int code, String message, Object... params) { super(message); this.code = code; this.params = params; this.message = StrUtil.format(message, params); } public BusinessException(String message, Throwable cause) { super(message, cause); } }