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

wuweijie 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 c95d62c204a Refactor NotClusterModeException (#30767)
c95d62c204a is described below

commit c95d62c204a0e71d493389093812fdc2cdace9ff
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Apr 4 13:59:56 2024 +0800

    Refactor NotClusterModeException (#30767)
    
    * Refactor NotClusterModeException
    
    * Refactor InvalidVariableValueException
    
    * Refactor MissingRequiredDatabaseException
    
    * Refactor MissingRequiredDatabaseException
    
    * Refactor PluginNotFoundException
---
 .../user-manual/error-code/sql-error-code.cn.md    | 23 ++++++-------
 .../user-manual/error-code/sql-error-code.en.md    | 38 ++++++----------------
 .../metadata/ColumnNotFoundException.java          |  2 +-
 .../metadata/MissingRequiredDatabaseException.java | 12 +++----
 .../metadata/SchemaNotFoundException.java          |  2 +-
 .../exception/metadata/TableNotFoundException.java |  4 +--
 .../syntax}/InvalidVariableValueException.java     |  8 ++---
 .../executor/ral/plugin/ShowPluginsExecutor.java   |  2 +-
 .../required/DistSQLExecutorRequiredChecker.java   |  4 +--
 .../sql/type/generic}/PluginNotFoundException.java |  7 ++--
 .../mode/exception/NotClusterModeException.java    | 12 +++----
 .../exception/WorkIdAssignedException.java         |  2 +-
 .../ral/updatable/SetDistVariableExecutor.java     |  2 +-
 .../YamlDatabaseConfigurationImportExecutor.java   |  4 +--
 .../ImportDatabaseConfigurationExecutorTest.java   | 10 ++++--
 .../ral/updatable/SetDistVariableExecutorTest.java |  2 +-
 16 files changed, 58 insertions(+), 76 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 1a365ba831e..4040c33e4bb 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
@@ -16,9 +16,10 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 
|-----------|-------------|-------------------------------------------------------------------------------------|
 | HY000     | 10000       | Can not support 3-tier structure for actual data 
node '%s' with JDBC '%s'.          |
 | HY004     | 10001       | Invalid format for actual data node '%s'.          
                                 |
-| 42S02     | 10002       | Schema '%s' does not exist.                        
                                 |
-| 42S02     | 10003       | Table or view '%s' does not exist.                 
                                 |
-| 42S02     | 10004       | Unknown column '%s' in '%s'.                       
                                 |
+| 42S02     | 10010       | Database is required.                              
                                 |
+| 42S02     | 10011       | Schema '%s' does not exist.                        
                                 |
+| 42S02     | 10012       | Table or view '%s' does not exist.                 
                                 |
+| 42S02     | 10013       | Unknown column '%s' in '%s'.                       
                                 |
 | HY000     | 10100       | Can not %s storage units '%s'.                     
                                 |
 | 42S02     | 10101       | There is no storage unit in database '%s'.         
                                 |
 | 44000     | 10102       | Storage units '%s' do not exist in database '%s'.  
                                 |
@@ -56,6 +57,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 |-----------|-------------|------------------------------------------|
 | 42000     | 12000       | SQL String can not be NULL or empty.     |
 | 42000     | 12010       | Can not support variable '%s'.           |
+| HY004     | 12011       | Invalid variable value '%s'.             |
 | HV008     | 12020       | Column index '%d' is out of range.       |
 | 42S02     | 12021       | Can not find column label '%s'.          |
 | HY000     | 12022       | Column '%s' in %s is ambiguous.          |
@@ -99,7 +101,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 
 | SQL State | Vendor Code | 错误信息                                               
           |
 
|-----------|-------------|---------------------------------------------------------------|
-| HY000     | 17000       | Work ID assigned failed, which can not exceed 
1024.           |
+| 44000     | 17000       | Mode must be 'cluster'.                            
           |
+| HY000     | 17001       | Work ID assigned failed, which can not exceed 
1024.           |
 | HY000     | 17002       | File access failed, file is: %s                    
           |
 | HY000     | 17010       | Cluster persist repository error, reason is: %s    
           |
 | HY000     | 17020       | The cluster status is %s, can not support SQL 
statement '%s'. |
@@ -138,13 +141,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | HY000     | 18201       | CDC server exception, reason is: %s.               
                               |
 | HY000     | 18202       | CDC login failed, reason is: %s                    
                               |
 
-### DistSQL
-
-| SQL State | Vendor Code | 错误信息                                               
         |
-|-----------|-------------|-------------------------------------------------------------|
-| 44000     | 19154       | Invalid mode, error message is: \`%s\`.            
         |
-| 44000     | 19155       | Plugin class \`%s\` not found..                    
         |
-
 ## 功能异常
 
 ### 数据分片
@@ -257,8 +253,9 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 
 | SQL State | Vendor Code | 错误信息                            |
 |-----------|-------------|---------------------------------|
-| HY004     | 30000       | Unknown exception: %s           |
+| HY000     | 30000       | Unknown exception: %s           |
 | 0A000     | 30001       | Unsupported SQL operation: %s   |
 | 0A000     | 30002       | Database protocol exception: %s |
 | 0A000     | 30003       | Unsupported command: %s         |
-| 0A000     | 30004       | Server exception: %s            |
+| HY000     | 30004       | Server exception: %s            |
+| HY000     | 30010       | Can not find plugin class '%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 cbce522b4f4..8e37d412b8f 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
@@ -16,9 +16,10 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 
|-----------|-------------|-------------------------------------------------------------------------------------|
 | HY000     | 10000       | Can not support 3-tier structure for actual data 
node '%s' with JDBC '%s'.          |
 | HY004     | 10001       | Invalid format for actual data node '%s'.          
                                 |
-| 42S02     | 10002       | Schema '%s' does not exist.                        
                                 |
-| 42S02     | 10003       | Table or view '%s' does not exist.                 
                                 |
-| 42S02     | 10004       | Unknown column '%s' in '%s'.                       
                                 |
+| 42S02     | 10010       | Database is required.                              
                                 |
+| 42S02     | 10011       | Schema '%s' does not exist.                        
                                 |
+| 42S02     | 10012       | Table or view '%s' does not exist.                 
                                 |
+| 42S02     | 10013       | Unknown column '%s' in '%s'.                       
                                 |
 | HY000     | 10100       | Can not %s storage units '%s'.                     
                                 |
 | 42S02     | 10101       | There is no storage unit in database '%s'.         
                                 |
 | 44000     | 10102       | Storage units '%s' do not exist in database '%s'.  
                                 |
@@ -56,6 +57,7 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 |-----------|-------------|------------------------------------------|
 | 42000     | 12000       | SQL String can not be NULL or empty.     |
 | 42000     | 12010       | Can not support variable '%s'.           |
+| HY004     | 12011       | Invalid variable value '%s'.             |
 | HV008     | 12020       | Column index '%d' is out of range.       |
 | 42S02     | 12021       | Can not find column label '%s'.          |
 | HY000     | 12022       | Column '%s' in %s is ambiguous.          |
@@ -99,7 +101,8 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 
 | SQL State | Vendor Code | Reason                                             
           |
 
|-----------|-------------|---------------------------------------------------------------|
-| HY000     | 17000       | Work ID assigned failed, which can not exceed 
1024.           |
+| 44000     | 17000       | Mode must be 'cluster'.                            
           |
+| HY000     | 17001       | Work ID assigned failed, which can not exceed 
1024.           |
 | HY000     | 17002       | File access failed, file is: %s                    
           |
 | HY000     | 17010       | Cluster persist repository error, reason is: %s    
           |
 | HY000     | 17020       | The cluster status is %s, can not support SQL 
statement '%s'. |
@@ -138,13 +141,6 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | HY000     | 18201       | CDC server exception, reason is: %s.               
                               |
 | HY000     | 18202       | CDC login failed, reason is: %s                    
                               |
 
-### DistSQL
-
-| SQL State | Vendor Code | Reason                                             
        |
-|-----------|-------------|------------------------------------------------------------|
-| 44000     | 19154       | Invalid mode, error message is: \`%s\`.            
        |
-| 44000     | 19155       | Plugin class \`%s\` not found..                    
        |
-
 ## Feature Exception
 
 ### Data Sharding
@@ -206,21 +202,6 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 44000     | 20295       | Auto aware data source name is required in 
database \`%s\.`        |
 | 44000     | 20296       | Read storage unit '%s' does not exist in rule 
'%s'.                |
 
-### Database HA
-
-| SQL State | Vendor Code | Reason                                             
                          |
-|-----------|-------------|------------------------------------------------------------------------------|
-| 44000     | 20300       | No available database discovery rule configuration 
in database \`%s\`.       |
-| 44000     | 20301       | Group name is required.                            
                          |
-| 44000     | 20302       | Data source names are required.                    
                          |
-| 44000     | 20303       | Can not found database discovery data source rule 
in database \`%s\`.        |
-| HY000     | 20380       | MGR plugin is not active in database \`%s\`.       
                          |
-| 44000     | 20381       | MGR is not in single primary mode in database 
\`%s\`.                        |
-| 44000     | 20382       | \`%s\` is not in MGR replication group member in 
database \`%s\`.            |
-| 44000     | 20383       | Group name in MGR is not same with configured one 
\`%s\` in database \`%s\`. |
-| 42S01     | 20390       | MySQL Duplicate primary data source in database 
\`%s\`.                      |
-| 42S02     | 20391       | Primary data source not found in database \`%s\`.  
                          |
-
 ### SQL Dialect Translator
 
 | SQL State | Vendor Code | Reason                                             
 |
@@ -272,8 +253,9 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 
 | SQL State | Vendor Code | Reason                          |
 |-----------|-------------|---------------------------------|
-| HY004     | 30000       | Unknown exception: %s           |
+| HY000     | 30000       | Unknown exception: %s           |
 | 0A000     | 30001       | Unsupported SQL operation: %s   |
 | 0A000     | 30002       | Database protocol exception: %s |
 | 0A000     | 30003       | Unsupported command: %s         |
-| 0A000     | 30004       | Server exception: %s            |
+| HY000     | 30004       | Server exception: %s            |
+| HY000     | 30010       | Can not find plugin class '%s'. |
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/ColumnNotFoundException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/ColumnNotFoundException.java
index 85ccaf3fbad..7453b32b5ea 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/ColumnNotFoundException.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/ColumnNotFoundException.java
@@ -28,6 +28,6 @@ public final class ColumnNotFoundException extends 
MetaDataSQLException {
     private static final long serialVersionUID = -1305402273592303335L;
     
     public ColumnNotFoundException(final String columnExpression, final String 
segmentTypeMessage) {
-        super(XOpenSQLState.NOT_FOUND, 4, "Unknown column '%s' in '%s'.", 
columnExpression, segmentTypeMessage);
+        super(XOpenSQLState.NOT_FOUND, 13, "Unknown column '%s' in '%s'.", 
columnExpression, segmentTypeMessage);
     }
 }
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/exception/MissingDatabaseNameException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/MissingRequiredDatabaseException.java
similarity index 74%
rename from 
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/exception/MissingDatabaseNameException.java
rename to 
infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/MissingRequiredDatabaseException.java
index 7f40db6a149..b7ca65339d0 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/exception/MissingDatabaseNameException.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/MissingRequiredDatabaseException.java
@@ -15,19 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.exception;
+package org.apache.shardingsphere.infra.exception.metadata;
 
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
+import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.MetaDataSQLException;
 
 /**
- * Missing database name exception.
+ * Missing required database exception.
  */
-public final class MissingDatabaseNameException extends DistSQLException {
+public final class MissingRequiredDatabaseException extends 
MetaDataSQLException {
     
     private static final long serialVersionUID = -1248634756191801109L;
     
-    public MissingDatabaseNameException() {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 8, "Missing required 
property `databaseName`.");
+    public MissingRequiredDatabaseException() {
+        super(XOpenSQLState.NOT_FOUND, 10, "Database is required.");
     }
 }
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/SchemaNotFoundException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/SchemaNotFoundException.java
index 7d651fb6664..2db90436dcf 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/SchemaNotFoundException.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/SchemaNotFoundException.java
@@ -28,6 +28,6 @@ public final class SchemaNotFoundException extends 
MetaDataSQLException {
     private static final long serialVersionUID = 2722045034640737328L;
     
     public SchemaNotFoundException(final String schemaName) {
-        super(XOpenSQLState.NOT_FOUND, 2, "Schema '%s' does not exist.", 
schemaName);
+        super(XOpenSQLState.NOT_FOUND, 11, "Schema '%s' does not exist.", 
schemaName);
     }
 }
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/TableNotFoundException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/TableNotFoundException.java
index bdfad7da3a3..50d3a0c9fbd 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/TableNotFoundException.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/metadata/TableNotFoundException.java
@@ -28,10 +28,10 @@ public final class TableNotFoundException extends 
MetaDataSQLException {
     private static final long serialVersionUID = -2507596759730534895L;
     
     public TableNotFoundException(final String tableName) {
-        super(XOpenSQLState.NOT_FOUND, 3, "Table or view '%s' does not 
exist.", tableName);
+        super(XOpenSQLState.NOT_FOUND, 12, "Table or view '%s' does not 
exist.", tableName);
     }
     
     public TableNotFoundException(final String tableName, final String 
storageUnitName) {
-        super(XOpenSQLState.NOT_FOUND, 3, "Table or view '%s' does not exist 
in storage unit '%s'.", tableName, storageUnitName);
+        super(XOpenSQLState.NOT_FOUND, 12, "Table or view '%s' does not exist 
in storage unit '%s'.", tableName, storageUnitName);
     }
 }
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidVariableValueException.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/syntax/InvalidVariableValueException.java
similarity index 81%
rename from 
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidVariableValueException.java
rename to 
infra/common/src/main/java/org/apache/shardingsphere/infra/exception/syntax/InvalidVariableValueException.java
index 2820c3ffc9a..a7bb5758b5b 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidVariableValueException.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/syntax/InvalidVariableValueException.java
@@ -15,19 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.exception;
+package org.apache.shardingsphere.infra.exception.syntax;
 
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
+import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.SyntaxSQLException;
 
 /**
  * Invalid variable value exception.
  */
-public final class InvalidVariableValueException extends DistSQLException {
+public final class InvalidVariableValueException extends SyntaxSQLException {
     
     private static final long serialVersionUID = 1840341880422454371L;
     
     public InvalidVariableValueException(final String value) {
-        super(XOpenSQLState.INVALID_DATA_TYPE, 0, "Invalid variable value 
`%s`.", value);
+        super(XOpenSQLState.INVALID_DATA_TYPE, 11, "Invalid variable value 
'%s'.", value);
     }
 }
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsExecutor.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsExecutor.java
index 88c1abc60e5..403cf504e7f 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsExecutor.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsExecutor.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.distsql.handler.executor.ral.plugin;
 
 import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
-import 
org.apache.shardingsphere.distsql.handler.exception.plugin.PluginNotFoundException;
+import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.PluginNotFoundException;
 import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
 import 
org.apache.shardingsphere.infra.database.core.spi.DatabaseSupportedTypedSPI;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/required/DistSQLExecutorRequiredChecker.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/required/DistSQLExecutorRequiredChecker.java
index 1c1194983e7..1abe8ec564e 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/required/DistSQLExecutorRequiredChecker.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/required/DistSQLExecutorRequiredChecker.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.distsql.handler.required;
 
 import lombok.RequiredArgsConstructor;
-import 
org.apache.shardingsphere.distsql.handler.exception.mode.InvalidModeException;
+import org.apache.shardingsphere.mode.exception.NotClusterModeException;
 import 
org.apache.shardingsphere.infra.exception.metadata.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.statement.rdl.rule.database.type.DropRuleStatement;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
@@ -50,7 +50,7 @@ public final class DistSQLExecutorRequiredChecker {
     }
     
     private void checkClusterMode(final ContextManager contextManager) {
-        
ShardingSpherePreconditions.checkState(contextManager.getInstanceContext().isCluster(),
 () -> new InvalidModeException("Mode must be `Cluster`"));
+        
ShardingSpherePreconditions.checkState(contextManager.getInstanceContext().isCluster(),
 NotClusterModeException::new);
     }
     
     private void checkCurrentRule(final SQLStatement sqlStatement, final 
ContextManager contextManager, final ShardingSphereDatabase database,
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/plugin/PluginNotFoundException.java
 
b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/generic/PluginNotFoundException.java
similarity index 75%
rename from 
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/plugin/PluginNotFoundException.java
rename to 
infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/generic/PluginNotFoundException.java
index b1c8f84d68f..5c58703f1df 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/plugin/PluginNotFoundException.java
+++ 
b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/generic/PluginNotFoundException.java
@@ -15,19 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.exception.plugin;
+package 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic;
 
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
 
 /**
  * Plugin not found exception.
  */
-public final class PluginNotFoundException extends DistSQLException {
+public final class PluginNotFoundException extends GenericSQLException {
     
     private static final long serialVersionUID = -2938352776606947755L;
     
     public PluginNotFoundException(final String pluginClass) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 155, String.format("Plugin 
class `%s` not found.", pluginClass));
+        super(XOpenSQLState.GENERAL_ERROR, 10, "Can not find plugin class 
'%s'.", pluginClass);
     }
 }
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/mode/InvalidModeException.java
 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/exception/NotClusterModeException.java
similarity index 73%
rename from 
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/mode/InvalidModeException.java
rename to 
mode/core/src/main/java/org/apache/shardingsphere/mode/exception/NotClusterModeException.java
index 36edff65c95..735bd23adf0 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/mode/InvalidModeException.java
+++ 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/exception/NotClusterModeException.java
@@ -15,19 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.exception.mode;
+package org.apache.shardingsphere.mode.exception;
 
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
+import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.ClusterSQLException;
 
 /**
- * Invalid mode exception.
+ * Not cluster mode exception.
  */
-public final class InvalidModeException extends DistSQLException {
+public final class NotClusterModeException extends ClusterSQLException {
     
     private static final long serialVersionUID = 7094702927472630479L;
     
-    public InvalidModeException(final String errorMessage) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 154, "Invalid mode, error 
message is: %s", errorMessage);
+    public NotClusterModeException() {
+        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 0, "Mode must be 
'cluster'.");
     }
 }
diff --git 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/exception/WorkIdAssignedException.java
 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/exception/WorkIdAssignedException.java
index b4981e319f7..2f1142f5aec 100644
--- 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/exception/WorkIdAssignedException.java
+++ 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/exception/WorkIdAssignedException.java
@@ -28,6 +28,6 @@ public final class WorkIdAssignedException extends 
ClusterSQLException {
     private static final long serialVersionUID = 4782736481041926266L;
     
     public WorkIdAssignedException() {
-        super(XOpenSQLState.GENERAL_ERROR, 0, "Work ID assigned failed, which 
can not exceed 1024.");
+        super(XOpenSQLState.GENERAL_ERROR, 1, "Work ID assigned failed, which 
can not exceed 1024.");
     }
 }
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutor.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutor.java
index f6058b81c86..580847f0c86 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutor.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutor.java
@@ -33,7 +33,7 @@ import 
org.apache.shardingsphere.logging.constant.LoggingConstants;
 import org.apache.shardingsphere.logging.util.LoggingUtils;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import 
org.apache.shardingsphere.proxy.backend.exception.InvalidVariableValueException;
+import 
org.apache.shardingsphere.infra.exception.syntax.InvalidVariableValueException;
 import 
org.apache.shardingsphere.infra.exception.syntax.UnsupportedVariableException;
 import org.slf4j.LoggerFactory;
 
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
index c4cfdf45114..681ccbccca7 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
@@ -47,7 +47,7 @@ import 
org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceCo
 import 
org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
 import 
org.apache.shardingsphere.proxy.backend.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import 
org.apache.shardingsphere.proxy.backend.exception.MissingDatabaseNameException;
+import 
org.apache.shardingsphere.infra.exception.metadata.MissingRequiredDatabaseException;
 
 import javax.sql.DataSource;
 import java.sql.SQLException;
@@ -90,7 +90,7 @@ public final class YamlDatabaseConfigurationImportExecutor {
     }
     
     private void checkDatabase(final String databaseName) {
-        ShardingSpherePreconditions.checkNotNull(databaseName, 
MissingDatabaseNameException::new);
+        ShardingSpherePreconditions.checkNotNull(databaseName, 
MissingRequiredDatabaseException::new);
         if (ProxyContext.getInstance().databaseExists(databaseName)) {
             
ShardingSpherePreconditions.checkState(ProxyContext.getInstance().getContextManager().getDatabase(databaseName).getResourceMetaData().getStorageUnits().isEmpty(),
                     () -> new 
UnsupportedSQLOperationException(String.format("Database `%s` exists and is not 
empty,overwrite is not supported", databaseName)));
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationExecutorTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationExecutorTest.java
index 10b81f0bc26..6ab74577e7a 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationExecutorTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationExecutorTest.java
@@ -36,7 +36,7 @@ import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundExce
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import 
org.apache.shardingsphere.proxy.backend.exception.MissingDatabaseNameException;
+import 
org.apache.shardingsphere.infra.exception.metadata.MissingRequiredDatabaseException;
 import 
org.apache.shardingsphere.proxy.backend.util.YamlDatabaseConfigurationImportExecutor;
 import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
 import org.apache.shardingsphere.test.fixture.jdbc.MockedDriver;
@@ -49,11 +49,13 @@ import org.mockito.internal.configuration.plugins.Plugins;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
 
+import java.net.URL;
 import java.sql.SQLException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Properties;
 
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
@@ -105,7 +107,7 @@ class ImportDatabaseConfigurationExecutorTest {
     
     @Test
     void assertImportEmptyDatabaseName() {
-        assertThrows(MissingDatabaseNameException.class, () -> 
assertExecute("sharding_db", "/conf/import/database-empty-database-name.yaml"));
+        assertThrows(MissingRequiredDatabaseException.class, () -> 
assertExecute("sharding_db", "/conf/import/database-empty-database-name.yaml"));
     }
     
     @Test
@@ -125,7 +127,9 @@ class ImportDatabaseConfigurationExecutorTest {
     
     private void assertExecute(final String databaseName, final String 
filePath) throws SQLException {
         init(databaseName);
-        executor.executeUpdate(new 
ImportDatabaseConfigurationStatement(ImportDatabaseConfigurationExecutorTest.class.getResource(filePath).getPath()),
 mock(ContextManager.class));
+        URL url = 
ImportDatabaseConfigurationExecutorTest.class.getResource(filePath);
+        assertNotNull(url);
+        executor.executeUpdate(new 
ImportDatabaseConfigurationStatement(url.getPath()), 
mock(ContextManager.class));
     }
     
     @SneakyThrows({IllegalAccessException.class, NoSuchFieldException.class})
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutorTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutorTest.java
index 54f36f9df2e..b449dee5442 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutorTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutorTest.java
@@ -34,7 +34,7 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
 import 
org.apache.shardingsphere.mode.manager.standalone.StandaloneModeContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import 
org.apache.shardingsphere.proxy.backend.exception.InvalidVariableValueException;
+import 
org.apache.shardingsphere.infra.exception.syntax.InvalidVariableValueException;
 import org.apache.shardingsphere.test.mock.AutoMockExtension;
 import org.apache.shardingsphere.test.mock.StaticMockSettings;
 import org.junit.jupiter.api.Test;


Reply via email to