|
|
@@ -2,7 +2,6 @@ package com.mrxu.framework.boot.handle;
|
|
|
|
|
|
|
|
|
import com.mrxu.framework.boot.feign.FeignProviderException;
|
|
|
-import com.mrxu.framework.boot.web.ServletUtils;
|
|
|
import com.mrxu.framework.common.util.BaseCode;
|
|
|
import com.mrxu.framework.common.util.BusinessException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -16,8 +15,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
/**
|
|
|
* @Author: xujunwei
|
|
|
* @Description: 此异常拦截给微服务提供方使用,不能与WebExceptionHandler 同时使用
|
|
|
@@ -46,6 +43,9 @@ public class FeignProviderExceptionHandler {
|
|
|
log.warn(e.getMessage());
|
|
|
return rendError(true,new BaseCode(error.getCode(),error.getMsg()),e);
|
|
|
}
|
|
|
+ if(e instanceof FeignProviderException) {
|
|
|
+ return e;
|
|
|
+ }
|
|
|
else if(e instanceof MethodArgumentNotValidException) {
|
|
|
MethodArgumentNotValidException error = (MethodArgumentNotValidException)e;
|
|
|
BindingResult result = error.getBindingResult();
|
|
|
@@ -61,7 +61,6 @@ public class FeignProviderExceptionHandler {
|
|
|
}
|
|
|
|
|
|
public Object rendError(boolean isBusinessException,BaseCode code, Throwable cause) {
|
|
|
- HttpServletRequest request = ServletUtils.getRequest();
|
|
|
FeignProviderException exception = new FeignProviderException(isBusinessException,serviceName,code,cause);
|
|
|
return exception;
|
|
|
}
|