提交 560a8e00 编写于 作者: T terrymanu

add ShardingRuleException

上级 de9e1200
......@@ -19,7 +19,6 @@ package io.shardingjdbc.core.rule;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import io.shardingjdbc.core.exception.ShardingJdbcException;
import io.shardingjdbc.core.keygen.KeyGenerator;
import io.shardingjdbc.core.parsing.parser.context.condition.Column;
import io.shardingjdbc.core.routing.strategy.ShardingStrategy;
......@@ -130,7 +129,7 @@ public final class ShardingRule {
if (null != defaultDataSourceName) {
return createTableRuleWithDefaultDataSource(logicTableName.toLowerCase());
}
throw new ShardingJdbcException("Cannot find table rule and default data source with logic table: '%s'", logicTableName);
throw new ShardingRuleException("Cannot find table rule and default data source with logic table: '%s'", logicTableName);
}
private TableRule createTableRuleWithDefaultDataSource(final String logicTableName) {
......@@ -274,7 +273,7 @@ public final class ShardingRule {
public Number generateKey(final String logicTableName) {
Optional<TableRule> tableRule = tryFindTableRuleByLogicTable(logicTableName);
if (!tableRule.isPresent()) {
throw new ShardingJdbcException("Cannot find strategy for generate keys.");
throw new ShardingRuleException("Cannot find strategy for generate keys.");
}
if (null != tableRule.get().getKeyGenerator()) {
return tableRule.get().getKeyGenerator().generateKey();
......@@ -294,7 +293,7 @@ public final class ShardingRule {
return each.getLogicTable();
}
}
throw new ShardingJdbcException("Cannot find logic table name with logic index name: '%s'", logicIndexName);
throw new ShardingRuleException("Cannot find logic table name with logic index name: '%s'", logicIndexName);
}
/**
......@@ -310,6 +309,6 @@ public final class ShardingRule {
return each;
}
}
throw new ShardingJdbcException("Cannot find actual data node for logic table name: '%s'", tableRule.getLogicTable());
throw new ShardingRuleException("Cannot find actual data node for logic table name: '%s'", tableRule.getLogicTable());
}
}
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package io.shardingjdbc.core.rule;
/**
* Sharding rule exception.
*
* @author zhangliang
*/
public final class ShardingRuleException extends RuntimeException {
private static final long serialVersionUID = -1360264079938958332L;
/**
* Constructs an exception with formatted error message and arguments.
*
* @param errorMessage formatted error message
* @param args arguments of error message
*/
public ShardingRuleException(final String errorMessage, final Object... args) {
super(String.format(errorMessage, args));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册