enhancement #IA8B3T 增强异常处理

This commit is contained in:
gaibu
2024-06-26 09:39:29 +08:00
parent 39bb14d852
commit cec048abc6
20 changed files with 76 additions and 51 deletions

View File

@@ -48,7 +48,7 @@ public class ApolloXmlELParser extends ClassXmlFlowELParser {
apolloParseHelper = new ApolloParseHelper(apolloParserConfigVO);
}
catch (Exception e) {
throw new ApolloException(e.getMessage());
throw new ApolloException(e);
}
}
@@ -65,7 +65,7 @@ public class ApolloXmlELParser extends ClassXmlFlowELParser {
}
catch (Exception e) {
throw new ApolloException(e.getMessage());
throw new ApolloException(e);
}
}

View File

@@ -13,6 +13,11 @@ public class ApolloException extends RuntimeException {
this.message = message;
}
public ApolloException(Throwable cause) {
super(cause);
this.message = cause.getMessage();
}
@Override
public String getMessage() {
return message;

View File

@@ -14,7 +14,6 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter;
import com.yomahub.liteflow.util.JsonUtil;
import java.util.Objects;
import java.util.function.BooleanSupplier;
/**
* Etcd解析器实现只支持EL形式的XML不支持其他的形式
@@ -53,7 +52,7 @@ public class EtcdXmlELParser extends ClassXmlFlowELParser {
etcdParserHelper = new EtcdParserHelper(etcdParserVO);
}
catch (Exception e) {
throw new EtcdException(e.getMessage());
throw new EtcdException(e);
}
}
@@ -71,7 +70,7 @@ public class EtcdXmlELParser extends ClassXmlFlowELParser {
return content;
}
catch (Exception e) {
throw new EtcdException(e.getMessage());
throw new EtcdException(e);
}
}

View File

@@ -9,22 +9,29 @@ package com.yomahub.liteflow.parser.etcd.exception;
*/
public class EtcdException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/** 异常信息 */
private String message;
/**
* 异常信息
*/
private String message;
public EtcdException(String message) {
this.message = message;
}
public EtcdException(String message) {
this.message = message;
}
@Override
public String getMessage() {
return message;
}
public EtcdException(Throwable cause) {
super(cause);
this.message = cause.getMessage();
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -64,7 +64,7 @@ public class EtcdParserHelper {
this.client = new EtcdClient(clientBuilder.build());
}
} catch (Exception e) {
throw new EtcdException(e.getMessage());
throw new EtcdException(e);
}
}
@@ -114,7 +114,7 @@ public class EtcdParserHelper {
return StrUtil.format(XML_PATTERN, scriptAllContent, chainAllContent);
} catch (Exception e) {
throw new EtcdException(e.getMessage());
throw new EtcdException(e);
}
}

View File

@@ -69,7 +69,7 @@ public class NacosXmlELParser extends ClassXmlFlowELParser {
helper = new NacosParserHelper(nacosParserVO);
}
catch (Exception e) {
throw new NacosException(e.getMessage());
throw new NacosException(e);
}
}
@@ -90,7 +90,7 @@ public class NacosXmlELParser extends ClassXmlFlowELParser {
return content;
}
catch (Exception e) {
throw new NacosException(e.getMessage());
throw new NacosException(e);
}
}

View File

@@ -12,6 +12,11 @@ public class NacosException extends RuntimeException {
this.message = message;
}
public NacosException(Throwable cause) {
super(cause);
this.message = cause.getMessage();
}
@Override
public String getMessage() {
return message;

View File

@@ -44,7 +44,7 @@ public class NacosParserHelper {
}
}
catch (Exception e) {
throw new NacosException(e.getMessage());
throw new NacosException(e);
}
}
@@ -76,7 +76,7 @@ public class NacosParserHelper {
return configService.getConfig(nacosParserVO.getDataId(), nacosParserVO.getGroup(), 3000L);
}
catch (Exception e) {
throw new NacosException(e.getMessage());
throw new NacosException(e);
}
}
@@ -109,7 +109,7 @@ public class NacosParserHelper {
});
}
catch (Exception ex) {
throw new NacosException(ex.getMessage());
throw new NacosException(ex);
}
}

View File

@@ -1,7 +1,5 @@
package com.yomahub.liteflow.parser.redis;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.StrFormatter;
@@ -11,10 +9,10 @@ import com.yomahub.liteflow.core.FlowInitHook;
import com.yomahub.liteflow.parser.el.ClassXmlFlowELParser;
import com.yomahub.liteflow.parser.redis.exception.RedisException;
import com.yomahub.liteflow.parser.redis.mode.RedisMode;
import com.yomahub.liteflow.parser.redis.mode.polling.RedisParserPollingMode;
import com.yomahub.liteflow.parser.redis.mode.subscribe.RedisParserSubscribeMode;
import com.yomahub.liteflow.parser.redis.mode.RedisParserHelper;
import com.yomahub.liteflow.parser.redis.mode.RedisParserMode;
import com.yomahub.liteflow.parser.redis.mode.polling.RedisParserPollingMode;
import com.yomahub.liteflow.parser.redis.mode.subscribe.RedisParserSubscribeMode;
import com.yomahub.liteflow.parser.redis.vo.RedisParserVO;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.property.LiteflowConfigGetter;
@@ -78,7 +76,7 @@ public class RedisXmlELParser extends ClassXmlFlowELParser {
throw redisException;
}
catch (Exception e) {
throw new RedisException(e.getMessage());
throw new RedisException(e);
}
}
@@ -94,7 +92,7 @@ public class RedisXmlELParser extends ClassXmlFlowELParser {
}
catch (Exception e) {
throw new RedisException(e.getMessage());
throw new RedisException(e);
}
}

View File

@@ -16,6 +16,11 @@ public class RedisException extends RuntimeException{
this.message = message;
}
public RedisException(Throwable cause) {
super(cause);
this.message = cause.getMessage();
}
@Override
public String getMessage() {
return message;

View File

@@ -114,7 +114,7 @@ public class RedisParserPollingMode implements RedisParserHelper {
}
}
catch (Exception e) {
throw new RedisException(e.getMessage());
throw new RedisException(e);
}
}
@@ -175,7 +175,7 @@ public class RedisParserPollingMode implements RedisParserHelper {
return StrUtil.format(XML_PATTERN, scriptAllContent, chainAllContent);
}
catch (Exception e) {
throw new RedisException(e.getMessage());
throw new RedisException(e);
}
}

View File

@@ -2,12 +2,8 @@ package com.yomahub.liteflow.parser.redis.mode.subscribe;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.parser.helper.NodeConvertHelper;
import com.yomahub.liteflow.parser.redis.exception.RedisException;
@@ -78,7 +74,7 @@ public class RedisParserSubscribeMode implements RedisParserHelper {
}
}
} catch (Exception e) {
throw new RedisException(e.getMessage());
throw new RedisException(e);
}
}
@@ -126,7 +122,7 @@ public class RedisParserSubscribeMode implements RedisParserHelper {
return StrUtil.format(XML_PATTERN, scriptAllContent, chainAllContent);
} catch (Exception e) {
throw new RedisException(e.getMessage());
throw new RedisException(e);
}
}

View File

@@ -64,7 +64,7 @@ public class SQLXmlELParser extends ClassXmlFlowELParser {
} catch (ELSQLException elsqlException) {
throw elsqlException;
} catch (Exception ex) {
throw new ELSQLException(ex.getMessage());
throw new ELSQLException(ex);
}
}
@@ -82,7 +82,7 @@ public class SQLXmlELParser extends ClassXmlFlowELParser {
}
return content;
} catch (Exception ex) {
throw new ELSQLException(ex.getMessage());
throw new ELSQLException(ex);
}
}

View File

@@ -19,6 +19,11 @@ public class ELSQLException extends RuntimeException {
this.message = message;
}
public ELSQLException(Throwable cause) {
super(cause);
this.message = cause.getMessage();
}
@Override
public String getMessage() {
return message;

View File

@@ -66,7 +66,7 @@ public abstract class AbstractSqlRead<T> implements SqlRead<T> {
result.add(parse(rs));
}
} catch (Exception e) {
throw new ELSQLException(e.getMessage());
throw new ELSQLException(e);
} finally {
// 关闭连接
LiteFlowJdbcUtil.close(conn, stmt, rs);

View File

@@ -71,7 +71,7 @@ public class JDBCHelper {
setPollExecutor(threadPoolExecutor);
}
} catch (ClassNotFoundException e) {
throw new ELSQLException(e.getMessage());
throw new ELSQLException(e);
}
}

View File

@@ -55,7 +55,7 @@ public class LiteFlowJdbcUtil {
}
} catch (Exception e) {
throw new ELSQLException(e.getMessage());
throw new ELSQLException(e);
}
return connection;
@@ -95,7 +95,7 @@ public class LiteFlowJdbcUtil {
try {
rs.close();
} catch (SQLException e) {
throw new ELSQLException(e.getMessage());
throw new ELSQLException(e);
}
}
// 关闭 statement
@@ -103,7 +103,7 @@ public class LiteFlowJdbcUtil {
try {
stmt.close();
} catch (SQLException e) {
throw new ELSQLException(e.getMessage());
throw new ELSQLException(e);
}
}
// 关闭连接
@@ -111,7 +111,7 @@ public class LiteFlowJdbcUtil {
try {
conn.close();
} catch (SQLException e) {
throw new ELSQLException(e.getMessage());
throw new ELSQLException(e);
}
}
}

View File

@@ -52,7 +52,7 @@ public class ZkXmlELParser extends ClassXmlFlowELParser {
zkParserHelper = new ZkParserHelper(zkParserVO);
}
catch (Exception e) {
throw new ZkException(e.getMessage());
throw new ZkException(e);
}
}
@@ -69,7 +69,7 @@ public class ZkXmlELParser extends ClassXmlFlowELParser {
return content;
}
catch (Exception e) {
throw new ZkException(e.getMessage());
throw new ZkException(e);
}
}

View File

@@ -12,6 +12,11 @@ public class ZkException extends RuntimeException {
this.message = message;
}
public ZkException(Throwable cause) {
super(cause);
this.message = cause.getMessage();
}
@Override
public String getMessage() {
return message;

View File

@@ -48,7 +48,7 @@ public class ZkParserHelper {
this.client = client;
} catch (Exception e) {
throw new ZkException(e.getMessage());
throw new ZkException(e);
}
}
@@ -98,7 +98,7 @@ public class ZkParserHelper {
return StrUtil.format(XML_PATTERN, scriptAllContent, chainAllContent);
} catch (Exception e) {
throw new ZkException(e.getMessage());
throw new ZkException(e);
}
}