refactor: 增加时序模块错误报告
This commit is contained in:
parent
c53e4522c1
commit
0878f81361
|
|
@ -17,6 +17,7 @@ package org.jetlinks.community.timescaledb.impl;
|
|||
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.r2dbc.spi.R2dbcBadGrammarException;
|
||||
import io.r2dbc.spi.R2dbcException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
|
@ -155,6 +156,10 @@ public class DefaultTimescaleDBDataWriter implements TimescaleDBDataWriter, Comm
|
|||
}
|
||||
|
||||
private boolean needRetry(Throwable err) {
|
||||
// 数据库语法错误?
|
||||
if (ErrorUtils.hasException(err, R2dbcBadGrammarException.class)) {
|
||||
return false;
|
||||
}
|
||||
return ErrorUtils.hasException(
|
||||
err,
|
||||
R2dbcException.class,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package org.jetlinks.community.timeseries.error;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hswebframework.web.exception.analyzer.ExceptionAnalyzerReporter;
|
||||
import org.jetlinks.community.timeseries.TimeSeriesManager;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
public class TimeseriesExceptionAnalyzerReporter extends ExceptionAnalyzerReporter {
|
||||
|
||||
|
||||
public TimeseriesExceptionAnalyzerReporter() {
|
||||
init();
|
||||
}
|
||||
|
||||
void init() {
|
||||
addReporter(
|
||||
err -> err instanceof NoSuchBeanDefinitionException &&
|
||||
Objects.equals(((NoSuchBeanDefinitionException) err).getBeanType(),
|
||||
TimeSeriesManager.class),
|
||||
err ->
|
||||
log.warn(wrapLog("请正确配置时序模块. 见文档: https://hanta.yuque.com/px7kg1/dev/xyr9mw8peqwtlhxc"), err));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
org.jetlinks.community.timeseries.error.TimeseriesExceptionAnalyzerReporter
|
||||
Loading…
Reference in New Issue