feat: 增加统一的业务异常拦截

This commit is contained in:
lilong 2024-03-20 16:41:47 +08:00
parent baabd470c7
commit 9625ab04d1

View File

@ -1,6 +1,7 @@
package cn.axzo.nanopart.config.exception;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.pokonyan.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.util.CollectionUtils;
@ -41,6 +42,12 @@ public class ExceptionAdviceHandler {
return ApiResult.err(e.getMessage());
}
@ExceptionHandler(BusinessException.class)
public ApiResult<Void> businessExceptionHandler(BusinessException e){
log.warn("业务异常", e);
return ApiResult.err(e.getErrorMsg());
}
@ExceptionHandler(BindException.class)
public ApiResult<Void> bindExceptionHandler(BindException e) {
log.warn("业务异常", e);