Browse Source

调整ResultDataResolver处理错误Result的返回信息

dev
wangxianzhang 4 years ago
parent
commit
9435160826
  1. 30
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java

30
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java

@ -51,24 +51,24 @@ public interface ResultDataResolver {
// 考虑到:上游服务抛出的异常代码和错误消息并不一定适用于当前服务,并且上有服务的错误消息弹出之后可能给用户造成困扰, // 考虑到:上游服务抛出的异常代码和错误消息并不一定适用于当前服务,并且上有服务的错误消息弹出之后可能给用户造成困扰,
// 因此,当前服务抛出异常的时候,不再继承上游服务返回的错误码和错误消息 // 因此,当前服务抛出异常的时候,不再继承上游服务返回的错误码和错误消息
if (!result.success()) {
Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode;
String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg;
throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL);
}
// if (!result.success()) { // if (!result.success()) {
// String j = JSON.toJSONString(result); // Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode;
// logger.info("远程调用出错,返回结果:{}", j); // String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg;
// // throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL);
// // 如果不通过参数指定code,则默认使用8000服务器开小差
// Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode;
// String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg;
// String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg;
//
// throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg);
// } // }
if (!result.success()) {
String j = JSON.toJSONString(result);
logger.info("远程调用出错,返回结果:{}", j);
// 如果不通过参数指定code,则默认使用8000服务器开小差
Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode;
String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg;
String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg;
throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg);
}
return result.getData(); return result.getData();
} }

Loading…
Cancel
Save