package com.kidgrow.common.exception;
|
|
import com.kidgrow.common.exception.code.BaseExceptionCode;
|
|
/**
|
* 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
|
*
|
* @Description: 业务异常,用于在处理业务逻辑时,进行抛出的异常<br>
|
* @Project: <br>
|
* @CreateDate: Created in 2020/2/11 11:59 <br>
|
* @Author: <a href="4345453@kidgrow.com">liuke</a>
|
*/
|
public class BizException extends KidgrowException{
|
private static final long serialVersionUID = -3843907364558373817L;
|
|
public BizException(String message) {
|
super(-1, message);
|
}
|
|
public BizException(int code, String message) {
|
super(code, message);
|
}
|
|
/**
|
* 实例化异常
|
*
|
* @param code 自定义异常编码
|
* @param message 自定义异常消息
|
* @return
|
*/
|
public static BizException wrap(int code, String message) {
|
return new BizException(code, message);
|
}
|
|
public static BizException wrap(String message) {
|
return new BizException(-1, message);
|
}
|
|
public static BizException validFail(String message) {
|
return new BizException(-9, message);
|
}
|
|
public static BizException wrap(BaseExceptionCode ex) {
|
return new BizException(ex.getCode(), ex.getMsg());
|
}
|
|
@Override
|
public String toString() {
|
return "BizException [message=" + getMsg() + ", code=" + getCode() + "]";
|
}
|
|
}
|