package com.pj.project4sp.global; import com.pj.constants.ErrorMsgEnum; import lombok.Data; /** * @author qzy * @description 业务异常 * @date Create in 2021/4/22 */ @Data public class BusinessException extends RuntimeException { private static final long serialVersionUID = -8661950806210020649L; private Integer code; /** * 验证的时候,手动抛该异常 * * @param errMsg 定义的错误信息 */ public BusinessException(String errMsg) { super(errMsg); this.code=500; } /** * 验证的时候,手动抛该异常 * * @param errMsg 定义的错误信息 */ public BusinessException(String errMsg, Integer code) { super(errMsg); this.code=code; } public BusinessException(ErrorMsgEnum errMsg) { super(errMsg.getMsg()); this.code=errMsg.getCode(); } /** * catch中抛该异常 * * @param errMsg 自定义的错误信息 * @param e 异常 */ public BusinessException(String errMsg, Throwable e) { super(errMsg, e); } }