REQ-3591: 处理异常问题
This commit is contained in:
parent
f1472986bc
commit
5cbe9d5e0f
@ -1,5 +1,16 @@
|
||||
package cn.axzo.msg.center.notices.client.handler;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.msg.center.notices.common.enums.ReturnCodeEnum;
|
||||
import cn.axzo.msg.center.notices.common.exception.BizException;
|
||||
@ -7,14 +18,6 @@ import cn.axzo.msg.center.notices.integration.client.DingDingClient;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Spring MVC 统一异常处理
|
||||
@ -24,6 +27,7 @@ import javax.annotation.Resource;
|
||||
* @since 2021-05-17 15:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
@RestControllerAdvice
|
||||
public class ControllerExceptionHandler {
|
||||
|
||||
@ -42,6 +46,12 @@ public class ControllerExceptionHandler {
|
||||
return CommonResponse.error(e.getErrorCode(), e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = cn.axzo.framework.domain.ServiceException.class)
|
||||
public CommonResponse bizException(cn.axzo.framework.domain.ServiceException e){
|
||||
log.warn("[mns] ControllerExceptionHandler.bizException Exception", e);
|
||||
return CommonResponse.error(9998, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = IllegalArgumentException.class)
|
||||
public CommonResponse handleIllegalArgumentException(IllegalArgumentException e) {
|
||||
LogUtil.error("[mns] ControllerExceptionHandler.handleIllegalArgumentException Exception message ", e);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user