|
|
@@ -43,24 +43,28 @@ public class FeignProviderExceptionHandler {
|
|
|
if(e instanceof BusinessException) {
|
|
|
BusinessException error = (BusinessException)e;
|
|
|
log.warn(e.getMessage());
|
|
|
- return rendError(true,new BaseCode(error.getCode(),error.getMsg()));
|
|
|
+ return rendError(true,new BaseCode(error.getCode(),error.getMsg()),e);
|
|
|
+ }
|
|
|
+ // 本身是微服务,调用其他微服务出错
|
|
|
+ else if(e instanceof FeignProviderException) {
|
|
|
+ return e;
|
|
|
}
|
|
|
else if(e instanceof MethodArgumentNotValidException) {
|
|
|
MethodArgumentNotValidException error = (MethodArgumentNotValidException)e;
|
|
|
BindingResult result = error.getBindingResult();
|
|
|
log.warn("请求参数错误:{}",result.getFieldError().getDefaultMessage());
|
|
|
- return rendError(true,BaseCode.ERR_PARAMS_VALID);
|
|
|
+ return rendError(true,BaseCode.ERR_PARAMS_VALID,e);
|
|
|
}
|
|
|
else if(e instanceof MissingServletRequestParameterException) {
|
|
|
log.warn("请求缺少参数:{}",e.getMessage());
|
|
|
- return rendError(true,BaseCode.ERR_PARAMS_MISS);
|
|
|
+ return rendError(true,BaseCode.ERR_PARAMS_MISS,e);
|
|
|
}
|
|
|
log.error("系统错误:{}",e.getMessage(), e);
|
|
|
- return rendError(false,new BaseCode(BaseCode.ERROR.code,e.getMessage()));
|
|
|
+ return rendError(false,new BaseCode(BaseCode.ERROR.code,e.getMessage()),e);
|
|
|
}
|
|
|
|
|
|
- public Object rendError(boolean isBusinessException,BaseCode code) {
|
|
|
- FeignProviderException exception = new FeignProviderException(isBusinessException,serviceName,code);
|
|
|
+ public Object rendError(boolean isBusinessException,BaseCode code,Throwable cause) {
|
|
|
+ FeignProviderException exception = new FeignProviderException(isBusinessException,serviceName,code,cause);
|
|
|
return exception;
|
|
|
}
|
|
|
|