This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new e58cb1b1ff4 Add new ShardingAlgorithmInitializationException to handle 
related exceptions (#23341)
e58cb1b1ff4 is described below

commit e58cb1b1ff4e96d9fad33689052aa8b875ea6474
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Thu Jan 5 15:28:37 2023 +0800

    Add new ShardingAlgorithmInitializationException to handle related 
exceptions (#23341)
---
 .../user-manual/error-code/sql-error-code.cn.md    | 27 +++++++++++-----------
 .../user-manual/error-code/sql-error-code.en.md    | 21 +++++++++--------
 .../EncryptAlgorithmInitializationException.java   |  2 +-
 .../MaskAlgorithmInitializationException.java      |  2 +-
 .../classbased/ClassBasedShardingAlgorithm.java    |  9 +++++---
 .../ClassBasedShardingAlgorithmFactory.java        |  2 +-
 .../complex/ComplexInlineShardingAlgorithm.java    |  3 ++-
 .../datetime/AutoIntervalShardingAlgorithm.java    |  8 ++++---
 .../datetime/IntervalShardingAlgorithm.java        | 12 ++++++----
 .../sharding/hint/HintInlineShardingAlgorithm.java |  5 ++--
 .../sharding/inline/InlineShardingAlgorithm.java   |  7 +++---
 .../sharding/mod/HashModShardingAlgorithm.java     |  5 ++--
 .../sharding/mod/ModShardingAlgorithm.java         | 20 ++++++++--------
 .../range/BoundaryBasedRangeShardingAlgorithm.java |  4 +++-
 .../range/VolumeBasedRangeShardingAlgorithm.java   | 11 +++++----
 .../GenerateKeyStrategyNotFoundException.java      |  2 +-
 ...rdingAlgorithmExpressionAndColumnException.java |  2 +-
 ...rdingAlgorithmClassImplementationException.java |  2 +-
 .../ShardingAlgorithmInitializationException.java} | 12 +++++-----
 .../ShardingRouteAlgorithmException.java           |  2 +-
 .../type/standard/StandardShardingStrategy.java    |  2 +-
 .../shardingsphere/sharding/rule/ShardingRule.java |  2 +-
 .../ClassBasedShardingAlgorithmFactoryTest.java    |  2 +-
 .../ClassBasedShardingAlgorithmTest.java           |  9 ++++----
 .../inline/InlineShardingAlgorithmTest.java        |  2 +-
 .../sharding/mod/ModShardingAlgorithmTest.java     |  5 ++--
 .../ShardingStandardRoutingEngineTest.java         |  2 +-
 .../sharding/rule/ShardingRuleTest.java            |  2 +-
 28 files changed, 102 insertions(+), 82 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md 
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index ca229d45792..6d5b80dfbb9 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -143,9 +143,9 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 
 ### 数据分片
 
-| SQL State | Vendor Code | 错误信息 |
-| --------- | ----------- | ------ |
-| 44000     | 20000       | Can not find table rule with logic tables \`%s\`. |
+| SQL State | Vendor Code | 错误信息                                               
                                                                        |
+| --------- 
|-------------|----------------------------------------------------------------------------------------------------------------------------|
+| 44000     | 20000       | Can not find table rule with logic tables \`%s\`.  
                                                                        |
 | 44000     | 20001       | Can not get uniformed table structure for logic 
table \`%s\`, it has different meta data of actual tables are as follows: %s |
 | 42S02     | 20002       | Can not find data source in sharding rule, invalid 
actual data node \`%s\`. |
 | 44000     | 20003       | Data nodes must be configured for sharding table 
\`%s\`. |
@@ -174,6 +174,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | HY000     | 20080       | Sharding algorithm class \`%s\` should be 
implement \`%s\`. |
 | HY000     | 20081       | Routed target \`%s\` does not exist, available 
targets are \`%s\`. |
 | 44000     | 20082       | Inline sharding algorithms expression \`%s\` and 
sharding column \`%s\` do not match. |
+| HY000     | 20083       | Sharding algorithm \`%s\` initialization failed, 
reason is: %s. |
 | 44000     | 20090       | Can not find strategy for generate keys with table 
\`%s\`. |
 | HY000     | 20099       | Sharding plugin error, reason is: %s |
 
@@ -207,14 +208,14 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 
 ### 数据加密
 
-| SQL State | Vendor Code | 错误信息 |
-| --------- | ----------- | ------ |
-| 44000     | 20700       | Can not find logic encrypt column by \`%s\`. |
-| 44000     | 20701       | Fail to find encrypt column \`%s\` from table 
\`%s\`. |
+| SQL State | Vendor Code | 错误信息                                               
                                                |
+| --------- | ----------- 
|----------------------------------------------------------------------------------------------------|
+| 44000     | 20700       | Can not find logic encrypt column by \`%s\`.       
                                                |
+| 44000     | 20701       | Fail to find encrypt column \`%s\` from table 
\`%s\`.                                              |
 | 44000     | 20702       | Altered column \`%s\` must use same encrypt 
algorithm with previous column \`%s\` in table \`%s\`. |
-| 42000     | 20740       | Insert value of index \`%s\` can not support for 
encrypt. |
-| 0A000     | 20741       | The SQL clause \`%s\` is unsupported in encrypt 
rule. |
-| HY004     | 20780       | Encrypt algorithm \`%s\` initialization failed, 
reason is: %s |
+| 42000     | 20740       | Insert value of index \`%s\` can not support for 
encrypt.                                          |
+| 0A000     | 20741       | The SQL clause \`%s\` is unsupported in encrypt 
rule.                                              |
+| HY004     | 20780       | Encrypt algorithm \`%s\` initialization failed, 
reason is: %s.                                     |
 
 ### 影子库
 
@@ -225,9 +226,9 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 
 ### 数据脱敏
 
-| SQL State | Vendor Code | 错误信息                                               
        |
-| --------- 
|-------------|------------------------------------------------------------|
-| HY000     | 20980       | Mask algorithm \`%s\` initialization failed, 
reason is: %s |
+| SQL State | Vendor Code | 错误信息                                               
         |
+| --------- 
|-------------|-------------------------------------------------------------|
+| HY000     | 20980       | Mask algorithm \`%s\` initialization failed, 
reason is: %s. |
 
 ## 其他异常
 
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md 
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 1fd61618b4c..d1195058719 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -174,6 +174,7 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | HY000     | 20080       | Sharding algorithm class \`%s\` should be 
implement \`%s\`. |
 | HY000     | 20081       | Routed target \`%s\` does not exist, available 
targets are \`%s\`. |
 | 44000     | 20082       | Inline sharding algorithms expression \`%s\` and 
sharding column \`%s\` do not match. |
+| HY000     | 20083       | Sharding algorithm \`%s\` initialization failed, 
reason is: %s. |
 | 44000     | 20090       | Can not find strategy for generate keys with table 
\`%s\`. |
 | HY000     | 20099       | Sharding plugin error, reason is: %s |
 
@@ -207,14 +208,14 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 
 ### Data Encrypt
 
-| SQL State | Vendor Code | Reason |
-| --------- | ----------- | ------ |
-| 44000     | 20700       | Can not find logic encrypt column by \`%s\`. |
-| 44000     | 20701       | Fail to find encrypt column \`%s\` from table 
\`%s\`. |
+| SQL State | Vendor Code | Reason                                             
                                                |
+| --------- | ----------- 
|----------------------------------------------------------------------------------------------------|
+| 44000     | 20700       | Can not find logic encrypt column by \`%s\`.       
                                                |
+| 44000     | 20701       | Fail to find encrypt column \`%s\` from table 
\`%s\`.                                              |
 | 44000     | 20702       | Altered column \`%s\` must use same encrypt 
algorithm with previous column \`%s\` in table \`%s\`. |
-| 42000     | 20740       | Insert value of index \`%s\` can not support for 
encrypt. |
-| 0A000     | 20741       | The SQL clause \`%s\` is unsupported in encrypt 
rule. |
-| HY004     | 20780       | Encrypt algorithm \`%s\` initialization failed, 
reason is: %s |
+| 42000     | 20740       | Insert value of index \`%s\` can not support for 
encrypt.                                          |
+| 0A000     | 20741       | The SQL clause \`%s\` is unsupported in encrypt 
rule.                                              |
+| HY004     | 20780       | Encrypt algorithm \`%s\` initialization failed, 
reason is: %s.                                     |
 
 ### Shadow Database
 
@@ -225,9 +226,9 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 
 ### Data Masking
 
-| SQL State | Vendor Code | Reason                                             
          |
-| --------- 
|-------------|------------------------------------------------------------|
-| HY000     | 20980       | Mask algorithm \`%s\` initialization failed, 
reason is: %s |
+| SQL State | Vendor Code | Reason                                             
         |
+| --------- 
|-------------|-------------------------------------------------------------|
+| HY000     | 20980       | Mask algorithm \`%s\` initialization failed, 
reason is: %s. |
 
 ## Other Exception
 
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/algorithm/EncryptAlgorithmInitializationException.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/algorithm/EncryptAlgorithmInitializationException.java
index 5962085ab07..7381a6938a4 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/algorithm/EncryptAlgorithmInitializationException.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/algorithm/EncryptAlgorithmInitializationException.java
@@ -28,6 +28,6 @@ public final class EncryptAlgorithmInitializationException 
extends EncryptSQLExc
     private static final long serialVersionUID = -2004166948563207100L;
     
     public EncryptAlgorithmInitializationException(final String encryptorType, 
final String reason) {
-        super(XOpenSQLState.GENERAL_ERROR, 80, "Encrypt algorithm `%s` 
initialization failed, reason is: %s", encryptorType, reason);
+        super(XOpenSQLState.GENERAL_ERROR, 80, "Encrypt algorithm `%s` 
initialization failed, reason is: %s.", encryptorType, reason);
     }
 }
diff --git 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/algorithm/MaskAlgorithmInitializationException.java
 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/algorithm/MaskAlgorithmInitializationException.java
index 70e22710117..c9b966d2158 100644
--- 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/algorithm/MaskAlgorithmInitializationException.java
+++ 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/algorithm/MaskAlgorithmInitializationException.java
@@ -28,6 +28,6 @@ public final class MaskAlgorithmInitializationException 
extends MaskSQLException
     private static final long serialVersionUID = -2004166948563207100L;
     
     public MaskAlgorithmInitializationException(final String maskType, final 
String reason) {
-        super(XOpenSQLState.GENERAL_ERROR, 80, "Mask algorithm `%s` 
initialization failed, reason is: %s", maskType, reason);
+        super(XOpenSQLState.GENERAL_ERROR, 80, "Mask algorithm `%s` 
initialization failed, reason is: %s.", maskType, reason);
     }
 }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
index b73c28c1cc7..14a9221366e 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
@@ -17,8 +17,8 @@
 
 package org.apache.shardingsphere.sharding.algorithm.sharding.classbased;
 
-import com.google.common.base.Preconditions;
 import lombok.Getter;
+import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
 import 
org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
@@ -26,6 +26,7 @@ import 
org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 
 import java.util.Collection;
 import java.util.Properties;
@@ -63,13 +64,15 @@ public final class ClassBasedShardingAlgorithm implements 
StandardShardingAlgori
     
     private ClassBasedShardingAlgorithmStrategyType getStrategy(final 
Properties props) {
         String strategy = props.getProperty(STRATEGY_KEY);
-        Preconditions.checkNotNull(strategy, "Properties `%s` can not be null 
when uses class based sharding strategy.", STRATEGY_KEY);
+        ShardingSpherePreconditions.checkNotNull(strategy,
+                () -> new ShardingAlgorithmInitializationException(getType(), 
String.format("Properties `%s` can not be null when uses class based sharding 
strategy.", STRATEGY_KEY)));
         return 
ClassBasedShardingAlgorithmStrategyType.valueOf(strategy.toUpperCase().trim());
     }
     
     private String getAlgorithmClassName(final Properties props) {
         String result = props.getProperty(ALGORITHM_CLASS_NAME_KEY);
-        Preconditions.checkNotNull(result, "Properties `%s` can not be null 
when uses class based sharding strategy.", ALGORITHM_CLASS_NAME_KEY);
+        ShardingSpherePreconditions.checkNotNull(result,
+                () -> new ShardingAlgorithmInitializationException(getType(), 
String.format("Properties `%s` can not be null when uses class based sharding 
strategy.", ALGORITHM_CLASS_NAME_KEY)));
         return result;
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactory.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactory.java
index abfb4d1af78..b3a30628218 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactory.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactory.java
@@ -20,7 +20,7 @@ package 
org.apache.shardingsphere.sharding.algorithm.sharding.classbased;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import lombok.SneakyThrows;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.ShardingAlgorithmClassImplementationException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmClassImplementationException;
 import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
 
 import java.util.Properties;
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
index 58bf57e3ba9..ff1d34bf570 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
@@ -26,6 +26,7 @@ import 
org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.
 import org.apache.shardingsphere.infra.util.expr.InlineExpressionParser;
 import 
org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
 import 
org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -67,7 +68,7 @@ public final class ComplexInlineShardingAlgorithm implements 
ComplexKeysSharding
     
     private String getAlgorithmExpression(final Properties props) {
         String algorithmExpression = 
props.getProperty(ALGORITHM_EXPRESSION_KEY);
-        Preconditions.checkNotNull(algorithmExpression, "Inline sharding 
algorithm expression can not be null.");
+        ShardingSpherePreconditions.checkNotNull(algorithmExpression, () -> 
new ShardingAlgorithmInitializationException(getType(), "Inline sharding 
algorithm expression can not be null."));
         return 
InlineExpressionParser.handlePlaceHolder(algorithmExpression.trim());
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
index d068f8a5888..6c78fbf3ee9 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
@@ -17,14 +17,15 @@
 
 package org.apache.shardingsphere.sharding.algorithm.sharding.datetime;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.Range;
 import lombok.Getter;
+import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.sharding.algorithm.sharding.ShardingAutoTableAlgorithmUtil;
 import 
org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 import 
org.apache.shardingsphere.sharding.exception.data.InvalidDatetimeFormatException;
 
 import java.text.DecimalFormat;
@@ -70,7 +71,7 @@ public final class AutoIntervalShardingAlgorithm implements 
StandardShardingAlgo
     
     private LocalDateTime getDateTime(final Properties props) {
         String value = props.getProperty(DATE_TIME_LOWER_KEY);
-        Preconditions.checkNotNull(value, "%s cannot be null.", 
DATE_TIME_LOWER_KEY);
+        ShardingSpherePreconditions.checkNotNull(value, () -> new 
ShardingAlgorithmInitializationException(getType(), String.format("%s cannot be 
null.", DATE_TIME_LOWER_KEY)));
         try {
             return LocalDateTime.parse(value, DATE_TIME_FORMAT);
         } catch (final DateTimeParseException ex) {
@@ -79,7 +80,8 @@ public final class AutoIntervalShardingAlgorithm implements 
StandardShardingAlgo
     }
     
     private long getShardingSeconds(final Properties props) {
-        Preconditions.checkArgument(props.containsKey(SHARDING_SECONDS_KEY), 
"%s cannot be null.", SHARDING_SECONDS_KEY);
+        
ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_SECONDS_KEY),
+                () -> new ShardingAlgorithmInitializationException(getType(), 
String.format("%s cannot be null.", SHARDING_SECONDS_KEY)));
         return Long.parseLong(props.getProperty(SHARDING_SECONDS_KEY));
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
index e6e1c1bfbb6..70bd08264ef 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
@@ -17,14 +17,15 @@
 
 package org.apache.shardingsphere.sharding.algorithm.sharding.datetime;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.BoundType;
 import com.google.common.collect.Range;
 import lombok.Getter;
+import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 import 
org.apache.shardingsphere.sharding.exception.data.InvalidDatetimeFormatException;
 
 import java.time.Instant;
@@ -96,12 +97,14 @@ public final class IntervalShardingAlgorithm implements 
StandardShardingAlgorith
     }
     
     private String getDateTimePattern(final Properties props) {
-        Preconditions.checkArgument(props.containsKey(DATE_TIME_PATTERN_KEY), 
"%s can not be null.", DATE_TIME_PATTERN_KEY);
+        
ShardingSpherePreconditions.checkState(props.containsKey(DATE_TIME_PATTERN_KEY),
+                () -> new ShardingAlgorithmInitializationException(getType(), 
String.format("%s can not be null.", DATE_TIME_PATTERN_KEY)));
         return props.getProperty(DATE_TIME_PATTERN_KEY);
     }
     
     private TemporalAccessor getDateTimeLower(final Properties props, final 
String dateTimePattern) {
-        Preconditions.checkArgument(props.containsKey(DATE_TIME_LOWER_KEY), 
"%s can not be null.", DATE_TIME_LOWER_KEY);
+        
ShardingSpherePreconditions.checkState(props.containsKey(DATE_TIME_LOWER_KEY),
+                () -> new ShardingAlgorithmInitializationException(getType(), 
String.format("%s can not be null.", DATE_TIME_LOWER_KEY)));
         return getDateTime(DATE_TIME_LOWER_KEY, 
props.getProperty(DATE_TIME_LOWER_KEY), dateTimePattern);
     }
     
@@ -118,7 +121,8 @@ public final class IntervalShardingAlgorithm implements 
StandardShardingAlgorith
     }
     
     private DateTimeFormatter getTableSuffixPattern(final Properties props) {
-        
Preconditions.checkArgument(props.containsKey(SHARDING_SUFFIX_FORMAT_KEY), "%s 
can not be null.", SHARDING_SUFFIX_FORMAT_KEY);
+        
ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_SUFFIX_FORMAT_KEY),
+                () -> new ShardingAlgorithmInitializationException(getType(), 
String.format("%s can not be null.", SHARDING_SUFFIX_FORMAT_KEY)));
         return 
DateTimeFormatter.ofPattern(props.getProperty(SHARDING_SUFFIX_FORMAT_KEY));
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
index a40b3274c0e..efb69509f99 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
@@ -17,13 +17,14 @@
 
 package org.apache.shardingsphere.sharding.algorithm.sharding.hint;
 
-import com.google.common.base.Preconditions;
 import groovy.lang.Closure;
 import groovy.util.Expando;
 import lombok.Getter;
+import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.util.expr.InlineExpressionParser;
 import 
org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
 import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 
 import java.util.Collection;
 import java.util.Properties;
@@ -53,7 +54,7 @@ public final class HintInlineShardingAlgorithm implements 
HintShardingAlgorithm<
     
     private String getAlgorithmExpression(final Properties props) {
         String algorithmExpression = 
props.getProperty(ALGORITHM_EXPRESSION_KEY, DEFAULT_ALGORITHM_EXPRESSION);
-        Preconditions.checkNotNull(algorithmExpression, "Inline sharding 
algorithm expression can not be null.");
+        ShardingSpherePreconditions.checkNotNull(algorithmExpression, () -> 
new ShardingAlgorithmInitializationException(getType(), "Inline sharding 
algorithm expression can not be null."));
         return 
InlineExpressionParser.handlePlaceHolder(algorithmExpression.trim());
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
index ab543c9e188..a8baa828d78 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.sharding.algorithm.sharding.inline;
 
-import com.google.common.base.Preconditions;
 import groovy.lang.Closure;
 import groovy.lang.MissingMethodException;
 import groovy.util.Expando;
@@ -28,7 +27,8 @@ import 
org.apache.shardingsphere.infra.util.expr.InlineExpressionParser;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.MismatchedInlineShardingAlgorithmExpressionAndColumnException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.MismatchedInlineShardingAlgorithmExpressionAndColumnException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 
 import java.util.Collection;
 import java.util.Properties;
@@ -58,7 +58,8 @@ public final class InlineShardingAlgorithm implements 
StandardShardingAlgorithm<
     
     private String getAlgorithmExpression(final Properties props) {
         String expression = props.getProperty(ALGORITHM_EXPRESSION_KEY);
-        Preconditions.checkState(null != expression && !expression.isEmpty(), 
"Inline sharding algorithm expression cannot be null or empty.");
+        ShardingSpherePreconditions.checkState(null != expression && 
!expression.isEmpty(),
+                () -> new ShardingAlgorithmInitializationException(getType(), 
"Inline sharding algorithm expression cannot be null or empty."));
         return InlineExpressionParser.handlePlaceHolder(expression.trim());
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
index 56ef1f636a6..1ee05d7bc45 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
@@ -17,13 +17,14 @@
 
 package org.apache.shardingsphere.sharding.algorithm.sharding.mod;
 
-import com.google.common.base.Preconditions;
 import lombok.Getter;
+import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.sharding.algorithm.sharding.ShardingAutoTableAlgorithmUtil;
 import 
org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 
 import java.util.Collection;
 import java.util.Properties;
@@ -47,7 +48,7 @@ public final class HashModShardingAlgorithm implements 
StandardShardingAlgorithm
     }
     
     private int getShardingCount(final Properties props) {
-        Preconditions.checkArgument(props.containsKey(SHARDING_COUNT_KEY), 
"Sharding count cannot be null.");
+        
ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_COUNT_KEY), 
() -> new ShardingAlgorithmInitializationException(getType(), "Sharding count 
cannot be null."));
         return Integer.parseInt(props.getProperty(SHARDING_COUNT_KEY));
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
index 39ab95c8b8d..8fd1633a13f 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
@@ -19,11 +19,13 @@ package 
org.apache.shardingsphere.sharding.algorithm.sharding.mod;
 
 import com.google.common.base.Preconditions;
 import lombok.Getter;
+import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.sharding.algorithm.sharding.ShardingAutoTableAlgorithmUtil;
 import 
org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 
 import java.math.BigInteger;
 import java.util.Collection;
@@ -67,16 +69,20 @@ public final class ModShardingAlgorithm implements 
StandardShardingAlgorithm<Com
     }
     
     private int getShardingCount(final Properties props) {
-        Preconditions.checkArgument(props.containsKey(SHARDING_COUNT_KEY), 
"Sharding count can not be null.");
+        
ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_COUNT_KEY), 
() -> new ShardingAlgorithmInitializationException(getType(), "Sharding count 
can not be null."));
         return Integer.parseInt(props.getProperty(SHARDING_COUNT_KEY));
     }
     
     private int getStartOffset(final Properties props) {
-        return 
Integer.parseInt(String.valueOf(props.getProperty(START_OFFSET_INDEX_KEY, 
"0")));
+        int result = 
Integer.parseInt(String.valueOf(props.getProperty(START_OFFSET_INDEX_KEY, 
"0")));
+        ShardingSpherePreconditions.checkState(result >= 0, () -> new 
ShardingAlgorithmInitializationException(getType(), "Start offset can not be 
less than 0."));
+        return result;
     }
     
     private int getStopOffset(final Properties props) {
-        return 
Integer.parseInt(String.valueOf(props.getProperty(STOP_OFFSET_INDEX_KEY, "0")));
+        int result = 
Integer.parseInt(String.valueOf(props.getProperty(STOP_OFFSET_INDEX_KEY, "0")));
+        ShardingSpherePreconditions.checkState(result >= 0, () -> new 
ShardingAlgorithmInitializationException(getType(), "Stop offset can not be 
less than 0."));
+        return result;
     }
     
     private boolean isZeroPadding(final Properties props) {
@@ -130,14 +136,8 @@ public final class ModShardingAlgorithm implements 
StandardShardingAlgorithm<Com
     }
     
     private BigInteger cutShardingValue(final Comparable<?> shardingValue) {
-        checkOffsetArgument(shardingValue);
-        return 0 == startOffset && 0 == stopOffset ? 
getBigInteger(shardingValue) : new 
BigInteger(shardingValue.toString().substring(startOffset, 
shardingValue.toString().length() - stopOffset));
-    }
-    
-    private void checkOffsetArgument(final Comparable<?> shardingValue) {
-        Preconditions.checkArgument(startOffset >= 0, "Start offset can not be 
less than 0.");
-        Preconditions.checkArgument(stopOffset >= 0, "Stop offset can not be 
less than 0.");
         Preconditions.checkArgument(shardingValue.toString().length() - 
stopOffset > startOffset, "Sharding value subtract stop offset can not be less 
than start offset.");
+        return 0 == startOffset && 0 == stopOffset ? 
getBigInteger(shardingValue) : new 
BigInteger(shardingValue.toString().substring(startOffset, 
shardingValue.toString().length() - stopOffset));
     }
     
     private BigInteger getBigInteger(final Comparable<?> value) {
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
index 8dbe7356c20..b41831681ad 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
@@ -21,6 +21,8 @@ import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Range;
 import com.google.common.primitives.Longs;
+import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 
 import java.util.HashMap;
 import java.util.List;
@@ -38,7 +40,7 @@ public final class BoundaryBasedRangeShardingAlgorithm 
extends AbstractRangeShar
     
     @Override
     public Map<Integer, Range<Comparable<?>>> calculatePartitionRange(final 
Properties props) {
-        Preconditions.checkState(props.containsKey(SHARDING_RANGES_KEY), 
"Sharding ranges cannot be null.");
+        
ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_RANGES_KEY), 
() -> new ShardingAlgorithmInitializationException(getType(), "Sharding ranges 
cannot be null."));
         List<Long> partitionRanges = 
Splitter.on(",").trimResults().splitToList(props.getProperty(SHARDING_RANGES_KEY))
                 
.stream().map(Longs::tryParse).filter(Objects::nonNull).sorted().collect(Collectors.toList());
         Preconditions.checkArgument(!partitionRanges.isEmpty(), "Sharding 
ranges is not valid.");
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
index 90cd104b78a..28f9f995678 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
@@ -17,9 +17,10 @@
 
 package org.apache.shardingsphere.sharding.algorithm.sharding.range;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.Range;
 import com.google.common.math.LongMath;
+import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 
 import java.math.RoundingMode;
 import java.util.HashMap;
@@ -39,13 +40,13 @@ public final class VolumeBasedRangeShardingAlgorithm 
extends AbstractRangeShardi
     
     @Override
     public Map<Integer, Range<Comparable<?>>> calculatePartitionRange(final 
Properties props) {
-        Preconditions.checkState(props.containsKey(RANGE_LOWER_KEY), "Lower 
range cannot be null.");
-        Preconditions.checkState(props.containsKey(RANGE_UPPER_KEY), "Upper 
range cannot be null.");
-        Preconditions.checkState(props.containsKey(SHARDING_VOLUME_KEY), 
"Sharding volume cannot be null.");
+        
ShardingSpherePreconditions.checkState(props.containsKey(RANGE_LOWER_KEY), () 
-> new ShardingAlgorithmInitializationException(getType(), "Lower range cannot 
be null."));
+        
ShardingSpherePreconditions.checkState(props.containsKey(RANGE_UPPER_KEY), () 
-> new ShardingAlgorithmInitializationException(getType(), "Upper range cannot 
be null."));
+        
ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_VOLUME_KEY), 
() -> new ShardingAlgorithmInitializationException(getType(), "Sharding volume 
cannot be null."));
         long lower = Long.parseLong(props.getProperty(RANGE_LOWER_KEY));
         long upper = Long.parseLong(props.getProperty(RANGE_UPPER_KEY));
         long volume = Long.parseLong(props.getProperty(SHARDING_VOLUME_KEY));
-        Preconditions.checkArgument(upper - lower >= volume, "Range can not be 
smaller than volume.");
+        ShardingSpherePreconditions.checkState(upper - lower >= volume, () -> 
new ShardingAlgorithmInitializationException(getType(), "Range can not be 
smaller than volume."));
         int partitionSize = Math.toIntExact(LongMath.divide(upper - lower, 
volume, RoundingMode.CEILING));
         Map<Integer, Range<Comparable<?>>> result = new 
HashMap<>(partitionSize + 2, 1);
         result.put(0, Range.lessThan(lower));
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/GenerateKeyStrategyNotFoundException.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/GenerateKeyStrategyNotFoundException.java
similarity index 95%
copy from 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/GenerateKeyStrategyNotFoundException.java
copy to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/GenerateKeyStrategyNotFoundException.java
index 56601133210..df5d68b643c 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/GenerateKeyStrategyNotFoundException.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/GenerateKeyStrategyNotFoundException.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.exception.algorithm;
+package org.apache.shardingsphere.sharding.exception.algorithm.keygen;
 
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
 import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/MismatchedInlineShardingAlgorithmExpressionAndColumnException.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/MismatchedInlineShardingAlgorithmExpressionAndColumnException.java
similarity index 95%
rename from 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/MismatchedInlineShardingAlgorithmExpressionAndColumnException.java
rename to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/MismatchedInlineShardingAlgorithmExpressionAndColumnException.java
index d21c029ad70..93810e53ff5 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/MismatchedInlineShardingAlgorithmExpressionAndColumnException.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/MismatchedInlineShardingAlgorithmExpressionAndColumnException.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.exception.algorithm;
+package org.apache.shardingsphere.sharding.exception.algorithm.sharding;
 
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
 import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/ShardingAlgorithmClassImplementationException.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmClassImplementationException.java
similarity index 95%
rename from 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/ShardingAlgorithmClassImplementationException.java
rename to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmClassImplementationException.java
index 259995b57ab..f304b069d51 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/ShardingAlgorithmClassImplementationException.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmClassImplementationException.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.exception.algorithm;
+package org.apache.shardingsphere.sharding.exception.algorithm.sharding;
 
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
 import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/GenerateKeyStrategyNotFoundException.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmInitializationException.java
similarity index 65%
rename from 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/GenerateKeyStrategyNotFoundException.java
rename to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmInitializationException.java
index 56601133210..0f7fd08f538 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/GenerateKeyStrategyNotFoundException.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingAlgorithmInitializationException.java
@@ -15,19 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.exception.algorithm;
+package org.apache.shardingsphere.sharding.exception.algorithm.sharding;
 
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
 import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
 
 /**
- * Generate key strategy not found exception.
+ * Sharding algorithm initialization exception.
  */
-public final class GenerateKeyStrategyNotFoundException extends 
ShardingSQLException {
+public final class ShardingAlgorithmInitializationException extends 
ShardingSQLException {
     
-    private static final long serialVersionUID = 7456922260524630374L;
+    private static final long serialVersionUID = -2638422150430534412L;
     
-    public GenerateKeyStrategyNotFoundException(final String tableName) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 90, "Can not find strategy 
for generate keys with table `%s`.", tableName);
+    public ShardingAlgorithmInitializationException(final String shardingType, 
final String reason) {
+        super(XOpenSQLState.GENERAL_ERROR, 83, "Sharding algorithm `%s` 
initialization failed, reason is: %s.", shardingType, reason);
     }
 }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/ShardingRouteAlgorithmException.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingRouteAlgorithmException.java
similarity index 95%
rename from 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/ShardingRouteAlgorithmException.java
rename to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingRouteAlgorithmException.java
index 3e91c6d11dc..454abe5d204 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/ShardingRouteAlgorithmException.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/sharding/ShardingRouteAlgorithmException.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.exception.algorithm;
+package org.apache.shardingsphere.sharding.exception.algorithm.sharding;
 
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
 import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/strategy/type/standard/StandardShardingStrategy.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/strategy/type/standard/StandardShardingStrategy.java
index e420f511fe8..8f43ce14c24 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/strategy/type/standard/StandardShardingStrategy.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/strategy/type/standard/StandardShardingStrategy.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.ShardingRouteAlgorithmException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingRouteAlgorithmException;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.value.ListShardingConditionValue;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.value.RangeShardingConditionValue;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index 01f87aabef1..63474f1220f 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -48,7 +48,7 @@ import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShard
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.GenerateKeyStrategyNotFoundException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.keygen.GenerateKeyStrategyNotFoundException;
 import 
org.apache.shardingsphere.sharding.exception.metadata.ShardingRuleNotFoundException;
 import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
 import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java
index 04b3335d97c..950d25f473d 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.sharding.algorithm.sharding.classbased;
 
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.ShardingAlgorithmClassImplementationException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmClassImplementationException;
 import 
org.apache.shardingsphere.sharding.fixture.ClassBasedHintShardingAlgorithmFixture;
 import 
org.apache.shardingsphere.sharding.fixture.ClassBasedStandardShardingAlgorithmFixture;
 import org.junit.Test;
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmTest.java
index a89be3f557d..90f599920c1 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmTest.java
@@ -25,7 +25,8 @@ import 
org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardi
 import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.ShardingAlgorithmClassImplementationException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmClassImplementationException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 import 
org.apache.shardingsphere.sharding.fixture.ClassBasedComplexKeysShardingAlgorithmFixture;
 import 
org.apache.shardingsphere.sharding.fixture.ClassBasedHintShardingAlgorithmFixture;
 import 
org.apache.shardingsphere.sharding.fixture.ClassBasedStandardShardingAlgorithmFixture;
@@ -43,9 +44,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 public final class ClassBasedShardingAlgorithmTest {
     
-    @Test(expected = NullPointerException.class)
+    @Test(expected = ShardingAlgorithmInitializationException.class)
     public void assertInitWithNullStrategy() {
-        Properties props = PropertiesBuilder.build(new Property("strategy", 
null));
+        Properties props = PropertiesBuilder.build();
         ShardingSphereAlgorithmFactory.createAlgorithm(new 
AlgorithmConfiguration("CLASS_BASED", props), ShardingAlgorithm.class);
     }
     
@@ -55,7 +56,7 @@ public final class ClassBasedShardingAlgorithmTest {
         ShardingSphereAlgorithmFactory.createAlgorithm(new 
AlgorithmConfiguration("CLASS_BASED", props), ShardingAlgorithm.class);
     }
     
-    @Test(expected = NullPointerException.class)
+    @Test(expected = ShardingAlgorithmInitializationException.class)
     public void assertInitWithNullClass() {
         Properties props = PropertiesBuilder.build(new Property("strategy", 
"standard"));
         ShardingSphereAlgorithmFactory.createAlgorithm(new 
AlgorithmConfiguration("CLASS_BASED", props), ShardingAlgorithm.class);
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java
index 286e7b18b9e..535a63ab7e3 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java
@@ -24,7 +24,7 @@ import 
org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.MismatchedInlineShardingAlgorithmExpressionAndColumnException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.MismatchedInlineShardingAlgorithmExpressionAndColumnException;
 import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
index d2a3b394677..85b08344e95 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
@@ -23,6 +23,7 @@ import 
org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
 import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
 import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -92,7 +93,7 @@ public final class ModShardingAlgorithmTest {
         assertThat(actual.size(), is(16));
     }
     
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = ShardingAlgorithmInitializationException.class)
     public void assertRangeDoShardingWithWrongArgumentForStartOffset() {
         Properties props = createZeroPaddingProperties();
         props.setProperty("start-offset", "-1");
@@ -100,7 +101,7 @@ public final class ModShardingAlgorithmTest {
         
assertThat(algorithm.doSharding(createAvailableIncludeZeroTargetNames(), new 
PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 
"12345678910111213141516")), is("t_order_07"));
     }
     
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = ShardingAlgorithmInitializationException.class)
     public void assertRangeDoShardingWithWrongArgumentForStopOffset() {
         Properties props = createZeroPaddingProperties();
         props.setProperty("stop-offset", "-1");
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngineTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngineTest.java
index a6dedbf6e43..a87767d40e2 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngineTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngineTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.hint.HintManager;
 import org.apache.shardingsphere.infra.hint.HintValueContext;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.ShardingRouteAlgorithmException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingRouteAlgorithmException;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingConditions;
 import 
org.apache.shardingsphere.sharding.route.engine.fixture.AbstractRoutingEngineTest;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index ec0ba6f3bc6..468d76c3bb0 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -42,7 +42,7 @@ import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexSh
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.exception.algorithm.GenerateKeyStrategyNotFoundException;
+import 
org.apache.shardingsphere.sharding.exception.algorithm.keygen.GenerateKeyStrategyNotFoundException;
 import 
org.apache.shardingsphere.sharding.exception.metadata.ShardingRuleNotFoundException;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;

Reply via email to