diff --git a/src/main/java/org/redkale/boot/Application.java b/src/main/java/org/redkale/boot/Application.java index 0d410a533..00d68c84c 100644 --- a/src/main/java/org/redkale/boot/Application.java +++ b/src/main/java/org/redkale/boot/Application.java @@ -746,7 +746,7 @@ public final class Application { } } } - logger.info("PropertiesAgent (type=" + this.propertiesAgent.getClass().getSimpleName() + ") load " + propCount + " data in " + (System.currentTimeMillis() - s) + " ms"); + logger.info("PropertiesAgent (type = " + this.propertiesAgent.getClass().getSimpleName() + ") load " + propCount + " data in " + (System.currentTimeMillis() - s) + " ms"); } break; } diff --git a/src/main/java/org/redkale/source/AbstractCacheSource.java b/src/main/java/org/redkale/source/AbstractCacheSource.java index 224fbe001..cdfba5356 100644 --- a/src/main/java/org/redkale/source/AbstractCacheSource.java +++ b/src/main/java/org/redkale/source/AbstractCacheSource.java @@ -91,7 +91,7 @@ public abstract class AbstractCacheSource extends AbstractService implements Cac source = (CacheSource) sourceType.getConstructor().newInstance(); } if (source == null) { - throw new RuntimeException("Not found CacheSourceProvider for config=" + sourceConf); + throw new SourceException("Not found CacheSourceProvider for config=" + sourceConf); } if (!compileMode && resourceFactory != null) { resourceFactory.inject(sourceName, source); diff --git a/src/main/java/org/redkale/source/AbstractDataSource.java b/src/main/java/org/redkale/source/AbstractDataSource.java index 8d42711cc..bd74de4ca 100644 --- a/src/main/java/org/redkale/source/AbstractDataSource.java +++ b/src/main/java/org/redkale/source/AbstractDataSource.java @@ -149,7 +149,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data source = (DataSource) sourceType.getConstructor().newInstance(); } if (source == null) { - throw new RuntimeException("Not found DataSourceProvider for config=" + sourceConf); + throw new SourceException("Not found DataSourceProvider for config=" + sourceConf); } if (!compileMode && resourceFactory != null) { resourceFactory.inject(sourceName, source); @@ -214,7 +214,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data } else if (url.startsWith("https://")) { info.servaddr = new InetSocketAddress(url0, 443); } else { - throw new RuntimeException(url + " parse port error"); + throw new SourceException(url + " parse port error"); } return info; } @@ -363,7 +363,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data if (clazz == null) { clazz = val.getClass(); if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + clazz + " must be on Annotation @Entity"); } continue; } @@ -373,7 +373,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data future.completeExceptionally(new RuntimeException("DataSource." + action + " must the same Class Entity, but diff is " + clazz + " and " + val.getClass())); return future; } - throw new RuntimeException("DataSource." + action + " must the same Class Entity, but diff is " + clazz + " and " + val.getClass()); + throw new SourceException("DataSource." + action + " must the same Class Entity, but diff is " + clazz + " and " + val.getClass()); } } return null; @@ -1338,7 +1338,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data for (T t : entitys) { Objects.requireNonNull(t); if (t.getClass().getAnnotation(Entity.class) == null && t.getClass().getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + t.getClass() + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + t.getClass() + " must be on Annotation @Entity"); } this.actions.add(new InsertBatchAction1(t)); } @@ -1350,7 +1350,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data for (T t : entitys) { Objects.requireNonNull(t); if (t.getClass().getAnnotation(Entity.class) == null && t.getClass().getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + t.getClass() + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + t.getClass() + " must be on Annotation @Entity"); } this.actions.add(new DeleteBatchAction1(t)); } @@ -1361,10 +1361,10 @@ public abstract class AbstractDataSource extends AbstractService implements Data public DataBatch delete(Class clazz, Serializable... pks) { Objects.requireNonNull(clazz); if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + clazz + " must be on Annotation @Entity"); } if (pks.length < 1) { - throw new RuntimeException("delete pk length is zero "); + throw new SourceException("delete pk length is zero "); } for (Serializable pk : pks) { Objects.requireNonNull(pk); @@ -1382,7 +1382,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data public DataBatch delete(Class clazz, FilterNode node, Flipper flipper) { Objects.requireNonNull(clazz); if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + clazz + " must be on Annotation @Entity"); } this.actions.add(new DeleteBatchAction3(clazz, node, flipper)); return this; @@ -1393,7 +1393,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data for (T t : entitys) { Objects.requireNonNull(t); if (t.getClass().getAnnotation(Entity.class) == null && t.getClass().getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + t.getClass() + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + t.getClass() + " must be on Annotation @Entity"); } this.actions.add(new UpdateBatchAction1(t)); } @@ -1409,11 +1409,11 @@ public abstract class AbstractDataSource extends AbstractService implements Data public DataBatch update(Class clazz, Serializable pk, ColumnValue... values) { Objects.requireNonNull(clazz); if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + clazz + " must be on Annotation @Entity"); } Objects.requireNonNull(pk); if (values.length < 1) { - throw new RuntimeException("update column-value length is zero "); + throw new SourceException("update column-value length is zero "); } for (ColumnValue val : values) { Objects.requireNonNull(val); @@ -1436,10 +1436,10 @@ public abstract class AbstractDataSource extends AbstractService implements Data public DataBatch update(Class clazz, FilterNode node, Flipper flipper, ColumnValue... values) { Objects.requireNonNull(clazz); if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + clazz + " must be on Annotation @Entity"); } if (values.length < 1) { - throw new RuntimeException("update column-value length is zero "); + throw new SourceException("update column-value length is zero "); } for (ColumnValue val : values) { Objects.requireNonNull(val); @@ -1451,7 +1451,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data @Override public DataBatch updateColumn(T entity, final String... columns) { if (columns.length < 1) { - throw new RuntimeException("update column length is zero "); + throw new SourceException("update column length is zero "); } for (String val : columns) { Objects.requireNonNull(val); @@ -1473,7 +1473,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data public DataBatch updateColumn(T entity, final FilterNode node, SelectColumn selects) { Objects.requireNonNull(entity); if (entity.getClass().getAnnotation(Entity.class) == null && entity.getClass().getAnnotation(javax.persistence.Entity.class) == null) { - throw new RuntimeException("Entity Class " + entity.getClass() + " must be on Annotation @Entity"); + throw new SourceException("Entity Class " + entity.getClass() + " must be on Annotation @Entity"); } Objects.requireNonNull(selects); this.actions.add(new UpdateBatchAction4(entity, node, selects)); diff --git a/src/main/java/org/redkale/source/CacheMemorySource.java b/src/main/java/org/redkale/source/CacheMemorySource.java index a05bb99b0..3b14a60b8 100644 --- a/src/main/java/org/redkale/source/CacheMemorySource.java +++ b/src/main/java/org/redkale/source/CacheMemorySource.java @@ -647,7 +647,7 @@ public final class CacheMemorySource extends AbstractCacheSource { @Override public void mset(Object... keyVals) { if (keyVals.length % 2 != 0) { - throw new RuntimeException("key value must be paired"); + throw new SourceException("key value must be paired"); } for (int i = 0; i < keyVals.length; i += 2) { String key = keyVals[i].toString(); diff --git a/src/main/java/org/redkale/source/DataJdbcSource.java b/src/main/java/org/redkale/source/DataJdbcSource.java index bce52341d..cd50f9c26 100644 --- a/src/main/java/org/redkale/source/DataJdbcSource.java +++ b/src/main/java/org/redkale/source/DataJdbcSource.java @@ -1021,7 +1021,7 @@ public class DataJdbcSource extends DataSqlSource { slowLog(s, sqls); return rs; } catch (SQLException e) { - throw new RuntimeException(e); + throw new SourceException(e); } finally { if (conn != null) writePool.offerConnection(conn); } @@ -1054,7 +1054,7 @@ public class DataJdbcSource extends DataSqlSource { slowLog(s, sql); return rs; } catch (Exception ex) { - throw new RuntimeException(ex); + throw new SourceException(ex); } finally { if (conn != null) readPool.offerConnection(conn); } @@ -1096,7 +1096,7 @@ public class DataJdbcSource extends DataSqlSource { try { return rr.next(); } catch (SQLException e) { - throw new RuntimeException(e); + throw new SourceException(e); } } @@ -1111,7 +1111,7 @@ public class DataJdbcSource extends DataSqlSource { } return labels; } catch (SQLException e) { - throw new RuntimeException(e); + throw new SourceException(e); } } @@ -1120,7 +1120,7 @@ public class DataJdbcSource extends DataSqlSource { try { return rr.wasNull(); } catch (SQLException e) { - throw new RuntimeException(e); + throw new SourceException(e); } } @@ -1129,7 +1129,7 @@ public class DataJdbcSource extends DataSqlSource { try { rr.close(); } catch (SQLException e) { - throw new RuntimeException(e); + throw new SourceException(e); } } @@ -1138,7 +1138,7 @@ public class DataJdbcSource extends DataSqlSource { try { return rr.getObject(index); } catch (SQLException e) { - throw new RuntimeException(e); + throw new SourceException(e); } } @@ -1147,7 +1147,7 @@ public class DataJdbcSource extends DataSqlSource { try { return rr.getObject(column); } catch (SQLException e) { - throw new RuntimeException(e); + throw new SourceException(e); } } @@ -1200,7 +1200,7 @@ public class DataJdbcSource extends DataSqlSource { try { this.driver = DriverManager.getDriver(this.url); } catch (SQLException e) { - throw new RuntimeException(e); + throw new SourceException(e); } clientInfo.put("version", String.valueOf(urlVersion)); } @@ -1257,7 +1257,7 @@ public class DataJdbcSource extends DataSqlSource { } catch (InterruptedException t) { logger.log(Level.WARNING, "take pooled connection error", t); } - if (conn == null) throw new RuntimeException("create pooled connection timeout"); + if (conn == null) throw new SourceException("create pooled connection timeout"); } } if (conn != null) { @@ -1275,7 +1275,7 @@ public class DataJdbcSource extends DataSqlSource { conn = driver.connect(url, connectAttrs); conn.setClientInfo(clientInfo); } catch (SQLException ex) { - throw new RuntimeException(ex); + throw new SourceException(ex); } usingCounter.increment(); creatCounter.increment(); diff --git a/src/main/java/org/redkale/source/DataResultSet.java b/src/main/java/org/redkale/source/DataResultSet.java index 0e6124600..f65de1700 100644 --- a/src/main/java/org/redkale/source/DataResultSet.java +++ b/src/main/java/org/redkale/source/DataResultSet.java @@ -152,7 +152,7 @@ public interface DataResultSet extends EntityInfo.DataResultSetRow { } } } catch (Exception e) { - throw new RuntimeException(row.getEntityInfo() + "." + attr.field() + ".value=" + o + ": " + e.getMessage(), e.getCause()); + throw new SourceException(row.getEntityInfo() + "." + attr.field() + ".value=" + o + ": " + e.getMessage(), e.getCause()); } return o; } diff --git a/src/main/java/org/redkale/source/DataSources.java b/src/main/java/org/redkale/source/DataSources.java index e9946faa9..abd5c1ef8 100644 --- a/src/main/java/org/redkale/source/DataSources.java +++ b/src/main/java/org/redkale/source/DataSources.java @@ -8,8 +8,7 @@ package org.redkale.source; import java.io.*; import java.net.*; import java.util.*; -import org.redkale.util.AnyValue; -import org.redkale.util.RedkaleClassLoader; +import org.redkale.util.*; /** * 常量放入 AbstractDataSource 类中,方法都已作废,persistence.xml 采用 source.properties 代替 @@ -117,7 +116,7 @@ public final class DataSources { // } // String url = readprop.getProperty(JDBC_URL); // dbtype = AbstractDataSource.parseDbtype(url); -// if (dbtype == null) throw new RuntimeException("not found datasource implements class, url=" + url); +// if (dbtype == null) throw new SourceException("not found datasource implements class, url=" + url); // // RedkaleClassLoader.putServiceLoader(DataSourceProvider.class); // Class dsClass = null; @@ -144,7 +143,7 @@ public final class DataSources { // dsClass = provider.sourceClass(); // if (dsClass != null) break; // } -// if (dsClass == null) throw new RuntimeException("not found datasource implements ServiceLoader, url=" + url); +// if (dsClass == null) throw new SourceException("not found datasource implements ServiceLoader, url=" + url); // impl = dsClass.getName(); // } // try { @@ -252,7 +251,7 @@ public final class DataSources { } catch (RuntimeException e) { throw e; } catch (Exception ex) { - throw new RuntimeException(ex); + throw new SourceException(ex); } } @@ -316,7 +315,7 @@ public final class DataSources { } in.close(); } catch (Exception ex) { - throw new RuntimeException(ex); + throw new SourceException(ex); } return map; } diff --git a/src/main/java/org/redkale/source/DataSqlSource.java b/src/main/java/org/redkale/source/DataSqlSource.java index 88cd920e4..214e0ef88 100644 --- a/src/main/java/org/redkale/source/DataSqlSource.java +++ b/src/main/java/org/redkale/source/DataSqlSource.java @@ -141,11 +141,11 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi //不支持读写分离模式的动态切换 if (readConfProps == writeConfProps && (events[0].name().startsWith("read.") || events[0].name().startsWith("write."))) { - throw new RuntimeException("DataSource(name=" + resourceName() + ") not support to change to read/write separation mode"); + throw new SourceException("DataSource(name=" + resourceName() + ") not support to change to read/write separation mode"); } if (readConfProps != writeConfProps && (!events[0].name().startsWith("read.") && !events[0].name().startsWith("write."))) { - throw new RuntimeException("DataSource(name=" + resourceName() + ") not support to change to non read/write separation mode"); + throw new SourceException("DataSource(name=" + resourceName() + ") not support to change to non read/write separation mode"); } StringBuilder sb = new StringBuilder(); @@ -1305,7 +1305,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi for (ColumnValue col : values) { if (col == null) continue; Attribute attr = info.getUpdateAttribute(col.getColumn()); - if (attr == null) throw new RuntimeException(info.getType() + " cannot found column " + col.getColumn()); + if (attr == null) throw new SourceException(info.getType() + " cannot found column " + col.getColumn()); if (setsql.length() > 0) setsql.append(", "); String sqlColumn = info.getSQLColumn(null, col.getColumn()); if (col.getValue() instanceof byte[]) { @@ -1316,7 +1316,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi setsql.append(sqlColumn).append("=").append(info.formatSQLValue(sqlColumn, attr, col, sqlFormatter)); } } - if (setsql.length() < 1) throw new RuntimeException("update non column-value array"); + if (setsql.length() < 1) throw new SourceException("update non column-value array"); String sql = "UPDATE " + info.getTable(pk) + " SET " + setsql + " WHERE " + info.getPrimarySQLColumn() + "=" + info.formatSQLValue(info.getPrimarySQLColumn(), pk, sqlFormatter); return new SqlInfo(sql, blobs); } @@ -1387,7 +1387,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi setsql.append(sqlColumn).append("=").append(info.formatSQLValue(sqlColumn, attr, col, sqlFormatter)); } } - if (setsql.length() < 1) throw new RuntimeException("update non column-value array"); + if (setsql.length() < 1) throw new SourceException("update non column-value array"); Map joinTabalis = node == null ? null : node.getJoinTabalis(); CharSequence join = node == null ? null : node.createSQLJoin(this, true, joinTabalis, new HashSet<>(), info); CharSequence where = node == null ? null : node.createSQLExpress(this, info, joinTabalis); @@ -1433,7 +1433,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi final EntityInfo info = loadEntityInfo(clazz); String illegalColumn = checkIllegalColumn(info, selects); if (illegalColumn != null) { - throw new RuntimeException(info.getType() + " cannot found column " + illegalColumn); + throw new SourceException(info.getType() + " cannot found column " + illegalColumn); } if (isOnlyCache(info)) return updateCache(info, -1, false, entity, null, selects); return this.updateColumnCompose(info, false, entity, null, selects).whenComplete((rs, t) -> { @@ -1480,7 +1480,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi final EntityInfo info = loadEntityInfo(clazz); String illegalColumn = checkIllegalColumn(info, selects); if (illegalColumn != null) { - throw new RuntimeException(info.getType() + " cannot found column " + illegalColumn); + throw new SourceException(info.getType() + " cannot found column " + illegalColumn); } if (isOnlyCache(info)) return updateCache(info, -1, true, entity, node, selects); return this.updateColumnCompose(info, true, entity, node, selects).whenComplete((rs, t) -> { diff --git a/src/main/java/org/redkale/source/EntityCache.java b/src/main/java/org/redkale/source/EntityCache.java index 979a5b821..9c537cb04 100644 --- a/src/main/java/org/redkale/source/EntityCache.java +++ b/src/main/java/org/redkale/source/EntityCache.java @@ -503,7 +503,7 @@ public final class EntityCache { OptionalDouble rs = stream.mapToDouble(x -> (Double) attrFunc.apply(x)).average(); return rs.isPresent() ? rs.getAsDouble() : defResult; } - throw new RuntimeException("getNumberResult error(type:" + type + ", attr.type: " + attrType); + throw new SourceException("getNumberResult error(type:" + type + ", attr.type: " + attrType); case COUNT: return stream.count(); case DISTINCTCOUNT: @@ -526,7 +526,7 @@ public final class EntityCache { OptionalDouble rs = stream.mapToDouble(x -> (Double) attrFunc.apply(x)).max(); return rs.isPresent() ? rs.getAsDouble() : defResult; } - throw new RuntimeException("getNumberResult error(type:" + type + ", attr.type: " + attrType); + throw new SourceException("getNumberResult error(type:" + type + ", attr.type: " + attrType); case MIN: if (attrType == int.class || attrType == Integer.class || attrType == AtomicInteger.class) { @@ -545,7 +545,7 @@ public final class EntityCache { OptionalDouble rs = stream.mapToDouble(x -> (Double) attrFunc.apply(x)).min(); return rs.isPresent() ? rs.getAsDouble() : defResult; } - throw new RuntimeException("getNumberResult error(type:" + type + ", attr.type: " + attrType); + throw new SourceException("getNumberResult error(type:" + type + ", attr.type: " + attrType); case SUM: if (attrType == int.class || attrType == Integer.class || attrType == AtomicInteger.class) { @@ -559,7 +559,7 @@ public final class EntityCache { } else if (attrType == double.class || attrType == Double.class) { return stream.mapToDouble(x -> (Double) attrFunc.apply(x)).sum(); } - throw new RuntimeException("getNumberResult error(type:" + type + ", attr.type: " + attrType); + throw new SourceException("getNumberResult error(type:" + type + ", attr.type: " + attrType); } return defResult; } @@ -980,13 +980,13 @@ public final class EntityCache { } else if (pattr.type() == double.class || pattr.type() == Double.class) { getter = x -> Math.abs(((Number) pattr.get((T) x)).doubleValue()); } else { - throw new RuntimeException("Flipper not supported sort illegal type by ABS (" + flipper.getSort() + ")"); + throw new SourceException("Flipper not supported sort illegal type by ABS (" + flipper.getSort() + ")"); } attr = (Attribute) Attribute.create(pattr.declaringClass(), pattr.field(), pattr.type(), getter, (o, v) -> pattr.set(o, v)); } else if (func.isEmpty()) { attr = pattr; } else { - throw new RuntimeException("Flipper not supported sort illegal function (" + flipper.getSort() + ")"); + throw new SourceException("Flipper not supported sort illegal function (" + flipper.getSort() + ")"); } } Comparator c = (sub.length > 1 && sub[1].equalsIgnoreCase("DESC")) ? (T o1, T o2) -> { diff --git a/src/main/java/org/redkale/source/EntityInfo.java b/src/main/java/org/redkale/source/EntityInfo.java index e0f59a5b5..9d1eca87e 100644 --- a/src/main/java/org/redkale/source/EntityInfo.java +++ b/src/main/java/org/redkale/source/EntityInfo.java @@ -309,7 +309,7 @@ public final class EntityInfo { } else { this.fullloader = fullloader; if (tableName0 != null && !tableName0.isEmpty() && tableName0.indexOf('.') >= 0) { - throw new RuntimeException(type + " have illegal table.name on @Table"); + throw new SourceException(type + " have illegal table.name on @Table"); } this.table = (tableCcatalog0 == null) ? type.getSimpleName().toLowerCase() : (tableCcatalog0.isEmpty()) ? (tableName0.isEmpty() ? type.getSimpleName().toLowerCase() : tableName0) : (tableCcatalog0 + '.' + (tableName0.isEmpty() ? type.getSimpleName().toLowerCase() : tableName0)); } @@ -405,20 +405,20 @@ public final class EntityInfo { attributeMap.put(fieldname, attr); } } while ((cltmp = cltmp.getSuperclass()) != Object.class); - if (idAttr0 == null) throw new RuntimeException(type.getName() + " have no primary column by @org.redkale.persistence.Id"); + if (idAttr0 == null) throw new SourceException(type.getName() + " have no primary column by @org.redkale.persistence.Id"); cltmp = type; JsonConvert convert = DEFAULT_JSON_CONVERT; do { for (Method method : cltmp.getDeclaredMethods()) { if (method.getAnnotation(SourceConvert.class) == null) continue; - if (!Modifier.isStatic(method.getModifiers())) throw new RuntimeException("@SourceConvert method(" + method + ") must be static"); - if (method.getReturnType() != JsonConvert.class) throw new RuntimeException("@SourceConvert method(" + method + ") must be return JsonConvert.class"); - if (method.getParameterCount() > 0) throw new RuntimeException("@SourceConvert method(" + method + ") must be 0 parameter"); + if (!Modifier.isStatic(method.getModifiers())) throw new SourceException("@SourceConvert method(" + method + ") must be static"); + if (method.getReturnType() != JsonConvert.class) throw new SourceException("@SourceConvert method(" + method + ") must be return JsonConvert.class"); + if (method.getParameterCount() > 0) throw new SourceException("@SourceConvert method(" + method + ") must be 0 parameter"); try { method.setAccessible(true); convert = (JsonConvert) method.invoke(null); } catch (Exception e) { - throw new RuntimeException(method + " invoke error", e); + throw new SourceException(method + " invoke error", e); } if (convert != null) break; } diff --git a/src/main/java/org/redkale/source/FilterNode.java b/src/main/java/org/redkale/source/FilterNode.java index ca9f76f47..350afed13 100644 --- a/src/main/java/org/redkale/source/FilterNode.java +++ b/src/main/java/org/redkale/source/FilterNode.java @@ -170,7 +170,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则 } protected FilterNode any(FilterNode node, boolean signor) { - if (this.readOnly) throw new RuntimeException("FilterNode(" + this + ") is ReadOnly"); + if (this.readOnly) throw new SourceException("FilterNode(" + this + ") is ReadOnly"); Objects.requireNonNull(node); if (this.column == null) { this.column = node.column; @@ -692,7 +692,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则 if (len == 0 && express == NOTIN) return null; final Class compType = valtype.getComponentType(); if (atype != compType && len > 0) { - if (!compType.isPrimitive() && Number.class.isAssignableFrom(compType)) throw new RuntimeException("param(" + val0 + ") type not match " + atype + " for column " + column); + if (!compType.isPrimitive() && Number.class.isAssignableFrom(compType)) throw new SourceException("param(" + val0 + ") type not match " + atype + " for column " + column); if (atype == int.class || atype == Integer.class) { int[] vs = new int[len]; for (int i = 0; i < len; i++) { @@ -786,7 +786,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则 final Serializable val = (Serializable) val0; final boolean fk = (val instanceof FilterKey); final Attribute fkattr = fk ? cache.getAttribute(((FilterKey) val).getColumn()) : null; - if (fk && fkattr == null) throw new RuntimeException(cache.getType() + " not found column(" + ((FilterKey) val).getColumn() + ")"); + if (fk && fkattr == null) throw new SourceException(cache.getType() + " not found column(" + ((FilterKey) val).getColumn() + ")"); switch (express) { case EQUAL: return fk ? new Predicate() { @@ -1075,7 +1075,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则 } }; default: - throw new RuntimeException("(" + fv0 + ")'s express illegal, must be =, !=, <, >, <=, >="); + throw new SourceException("(" + fv0 + ")'s express illegal, must be =, !=, <, >, <=, >="); } case FV_DIV: FilterValue fv1 = (FilterValue) val; @@ -1159,7 +1159,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则 } }; default: - throw new RuntimeException("(" + fv1 + ")'s express illegal, must be =, !=, <, >, <=, >="); + throw new SourceException("(" + fv1 + ")'s express illegal, must be =, !=, <, >, <=, >="); } case OPAND: return fk ? new Predicate() { diff --git a/src/main/java/org/redkale/source/FilterNodeBean.java b/src/main/java/org/redkale/source/FilterNodeBean.java index f80bc6ae6..8a4d149de 100644 --- a/src/main/java/org/redkale/source/FilterNodeBean.java +++ b/src/main/java/org/redkale/source/FilterNodeBean.java @@ -227,7 +227,7 @@ public final class FilterNodeBean implements Comparable + * 详情见: https://redkale.org + * + * @author zhangjx + * + * @since 2.8.0 + */ +public class SourceException extends RuntimeException { + + public SourceException() { + super(); + } + + public SourceException(String s) { + super(s); + } + + public SourceException(String message, Throwable cause) { + super(message, cause); + } + + public SourceException(Throwable cause) { + super(cause); + } +}