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

sunnianjun 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 35045eff842 Add MissingRequiredStrategyException (#30883)
35045eff842 is described below

commit 35045eff8426c7b6224c95466822a96713badeb2
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Apr 14 19:14:23 2024 +0800

    Add MissingRequiredStrategyException (#30883)
    
    * Add MissingRequiredStrategyException
    
    * Add MissingRequiredStrategyException
---
 .../user-manual/error-code/sql-error-code.cn.md        |  1 +
 .../user-manual/error-code/sql-error-code.en.md        |  1 +
 .../ReadwriteSplittingRuleStatementChecker.java        |  4 ++--
 .../rule/InvalidRuleConfigurationException.java        |  4 ----
 ...tion.java => MissingRequiredStrategyException.java} | 18 +++++-------------
 5 files changed, 9 insertions(+), 19 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 bd34d012b8d..7994f3ed0db 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
@@ -32,6 +32,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 10202       | 42S02     | %s rules '%s' do not exist in database '%s'.       
                                 |
 | 10203       | 44000     | %s rules '%s' in database '%s' are still in used.  
                                 |
 | 10204       | 42S01     | Duplicate %s rule names '%s' in database '%s'.     
                                 |
+| 10210       | 42S02     | %s strategies '%s' do not exist.                   
                                 |
 | 10300       | HY004     | Invalid format for actual data node '%s'.          
                                 |
 | 10301       | HY000     | Can not support 3-tier structure for actual data 
node '%s' with JDBC '%s'.          |
 | 10400       | 44000     | Algorithm '%s.'%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 8e98393c5e8..fd987707192 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
@@ -32,6 +32,7 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 10202       | 42S02     | %s rules '%s' do not exist in database '%s'.       
                                 |
 | 10203       | 44000     | %s rules '%s' in database '%s' are still in used.  
                                 |
 | 10204       | 42S01     | Duplicate %s rule names '%s' in database '%s'.     
                                 |
+| 10210       | 42S02     | %s strategies '%s' do not exist.                   
                                 |
 | 10300       | HY004     | Invalid format for actual data node '%s'.          
                                 |
 | 10301       | HY000     | Can not support 3-tier structure for actual data 
node '%s' with JDBC '%s'.          |
 | 10400       | 44000     | Algorithm '%s.'%s' initialization failed, reason 
is: %s.                            |
diff --git 
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
 
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
index 70614bd6ffd..190ed3f9321 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
@@ -26,6 +26,7 @@ import 
org.apache.shardingsphere.infra.exception.kernel.metadata.resource.storag
 import 
org.apache.shardingsphere.infra.exception.kernel.metadata.rule.DuplicateRuleException;
 import 
org.apache.shardingsphere.infra.exception.kernel.metadata.rule.InvalidRuleConfigurationException;
 import 
org.apache.shardingsphere.infra.exception.kernel.metadata.rule.MissingRequiredRuleException;
+import 
org.apache.shardingsphere.infra.exception.kernel.metadata.rule.MissingRequiredStrategyException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
 import 
org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
@@ -204,8 +205,7 @@ public final class ReadwriteSplittingRuleStatementChecker {
         for (ReadwriteSplittingRuleSegment each : segments) {
             if (null != each.getTransactionalReadQueryStrategy()) {
                 
ShardingSpherePreconditions.checkState(validStrategyNames.contains(each.getTransactionalReadQueryStrategy().toUpperCase()),
-                        () -> new InvalidRuleConfigurationException(
-                                "Readwrite-splitting", each.getName(), 
String.format("Invalid transactional read query strategy `%s`.", 
each.getTransactionalReadQueryStrategy())));
+                        () -> new 
MissingRequiredStrategyException("Transactional read query", 
Collections.singleton(each.getTransactionalReadQueryStrategy())));
             }
         }
     }
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/InvalidRuleConfigurationException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/InvalidRuleConfigurationException.java
index b68622d3e37..bee9426d9d7 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/InvalidRuleConfigurationException.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/InvalidRuleConfigurationException.java
@@ -28,10 +28,6 @@ public final class InvalidRuleConfigurationException extends 
RuleDefinitionExcep
     
     private static final long serialVersionUID = 6085010920008859376L;
     
-    public InvalidRuleConfigurationException(final String ruleType, final 
String rule, final String errorMessage) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Invalid '%s' rule 
'%s', error message is: %s", ruleType, rule, errorMessage);
-    }
-    
     public InvalidRuleConfigurationException(final String ruleType, final 
Collection<String> rules, final Collection<String> errorMessages) {
         super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Invalid '%s' rules 
'%s', error messages are: %s", ruleType, rules, errorMessages);
     }
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/InvalidRuleConfigurationException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/MissingRequiredStrategyException.java
similarity index 51%
copy from 
infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/InvalidRuleConfigurationException.java
copy to 
infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/MissingRequiredStrategyException.java
index b68622d3e37..39199419173 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/InvalidRuleConfigurationException.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/rule/MissingRequiredStrategyException.java
@@ -22,21 +22,13 @@ import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpe
 import java.util.Collection;
 
 /**
- * Invalid rule configuration exception.
+ * Missing required strategy exception.
  */
-public final class InvalidRuleConfigurationException extends 
RuleDefinitionException {
+public final class MissingRequiredStrategyException extends 
RuleDefinitionException {
     
-    private static final long serialVersionUID = 6085010920008859376L;
+    private static final long serialVersionUID = 1206159066784894689L;
     
-    public InvalidRuleConfigurationException(final String ruleType, final 
String rule, final String errorMessage) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Invalid '%s' rule 
'%s', error message is: %s", ruleType, rule, errorMessage);
-    }
-    
-    public InvalidRuleConfigurationException(final String ruleType, final 
Collection<String> rules, final Collection<String> errorMessages) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Invalid '%s' rules 
'%s', error messages are: %s", ruleType, rules, errorMessages);
-    }
-    
-    public InvalidRuleConfigurationException(final String ruleType, final 
String errorMessage) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Invalid '%s' rule, 
error message is: %s", ruleType, errorMessage);
+    public MissingRequiredStrategyException(final String strategyType, final 
Collection<String> ruleNames) {
+        super(XOpenSQLState.NOT_FOUND, 10, "%s strategies '%s' do not exist.", 
strategyType, ruleNames);
     }
 }

Reply via email to