init
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.newyetai.common.exception.util;
|
||||
|
||||
import com.newyetai.common.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 异常工具类
|
||||
* @author sr on 2019-10-14
|
||||
*/
|
||||
@Slf4j
|
||||
public class ExceptionUtils {
|
||||
|
||||
/**
|
||||
* @Description 抛异常
|
||||
* @Author chenyun.huang
|
||||
* @Date 2020/3/27 15:06
|
||||
**/
|
||||
public static void throwBusinessException(String msg) {
|
||||
ExceptionUtils.throwBusinessException(true,msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据判断抛异常
|
||||
* @param isThrow
|
||||
* @param msg 异常信息
|
||||
* @author sr on 2019-10-14
|
||||
*/
|
||||
public static void throwBusinessException(boolean isThrow, String msg) {
|
||||
if (isThrow) {
|
||||
throw new BusinessException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据判断抛异常
|
||||
* @param isThrow
|
||||
* @param errorMsg 异常信息
|
||||
* @param logMsg 日志信息(info级)
|
||||
* @author sr on 2019-12-18
|
||||
*/
|
||||
public static void throwBusinessException(boolean isThrow, String errorMsg, String logMsg) {
|
||||
if (isThrow) {
|
||||
log.info(logMsg);
|
||||
throw new BusinessException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user