完善 Dubbo Provider 异常过滤器,接入新的异常体系

This commit is contained in:
YunaiV
2020-07-19 01:34:44 +08:00
parent 32c1cfb3a7
commit c0407267b9
10 changed files with 90 additions and 51 deletions

View File

@@ -16,10 +16,13 @@ public class MallUtils {
* @return 链路追踪编号
*/
public static String getTraceId() {
String traceId = TraceContext.traceId();
if (StringUtils.hasText(traceId)) {
return traceId;
}
// 通过 SkyWalking 获取链路编号
try {
String traceId = TraceContext.traceId();
if (StringUtils.hasText(traceId)) {
return traceId;
}
} catch (Throwable ignore) {}
// TODO 芋艿 多次调用会问题
return UUID.randomUUID().toString();
}

View File

@@ -141,4 +141,14 @@ public final class CommonResult<T> implements Serializable {
throw new ServiceException(code, message).setDetailMessage(detailMessage);
}
public static <T> CommonResult<T> error(ServiceException serviceException) {
return error(serviceException.getCode(), serviceException.getMessage(),
serviceException.getDetailMessage());
}
public static <T> CommonResult<T> error(GlobalException globalException) {
return error(globalException.getCode(), globalException.getMessage(),
globalException.getDetailMessage());
}
}