自定义的业务类的异常,与断言一起使用

69 阅读1分钟
/**
 *业务类的异常,
 *继承一个已知的类RuntimeException
 *添加构造方法,调用父类的构造方法,----》把错误信息向上回传
 */
public class BusinessException extends RuntimeException{

    //错误码
    //private String code;
    //错误信息
    //private String message;
    //枚举
    private ResponseCode responseCode;

    public BusinessException() {
        super();
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(ResponseCode responseCode) {
        this.responseCode = responseCode;
    }

    public ResponseCode getResponseCode() {
        return responseCode;
    }

    public void setResponseCode(ResponseCode responseCode) {
        this.responseCode = responseCode;
    }
}