完善 Dubbo Provider 异常过滤器,接入新的异常体系
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user