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 119df65d628 Add SingleTablesLoadingException (#20761)
119df65d628 is described below

commit 119df65d628abd78989b1062402eb28f3068c25a
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Sep 4 14:43:06 2022 +0800

    Add SingleTablesLoadingException (#20761)
---
 .../content/user-manual/error-code/sql-error-code.cn.md      |  3 ++-
 .../content/user-manual/error-code/sql-error-code.en.md      |  3 ++-
 .../singletable/datanode/SingleTableDataNodeLoader.java      |  4 ++--
 .../singletable/exception/DropNotEmptySchemaException.java   |  2 +-
 ...chemaException.java => SingleTablesLoadingException.java} | 12 +++++++-----
 5 files changed, 14 insertions(+), 10 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 1d64f34a1de..d6cc9adcb3a 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
@@ -44,7 +44,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | HY000     | 16001       | Failed to get DDL for table \`%s\` |
 | 42S02     | 17000       | Single table \`%s\` does not exist |
 | 42S02     | 17001       | Schema \`%s\` does not exist |
-| 0A000     | 17002       | Can not drop schema \`%s\` because of contains 
tables |
+| HY000     | 17002       | Can not load table with database name \`%s\` and 
data source name \`%s\` |
+| 0A000     | 17003       | Can not drop schema \`%s\` because of contains 
tables |
 | 0A000     | 17010       | DROP TABLE ... CASCADE is not supported |
 | HY000     | 20000       | Sharding algorithm class \`%s\` should be 
implement \`%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 |
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 9681abc7d7b..6135a81675d 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
@@ -44,7 +44,8 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | HY000     | 16001       | Failed to get DDL for table \`%s\` |
 | 42S02     | 17000       | Single table \`%s\` does not exist |
 | 42S02     | 17001       | Schema \`%s\` does not exist |
-| 0A000     | 17002       | Can not drop schema \`%s\` because of contains 
tables |
+| HY000     | 17002       | Can not load table with database name \`%s\` and 
data source name \`%s\` |
+| 0A000     | 17003       | Can not drop schema \`%s\` because of contains 
tables |
 | 0A000     | 17010       | DROP TABLE ... CASCADE is not supported |
 | HY000     | 20000       | Sharding algorithm class \`%s\` should be 
implement \`%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 |
diff --git 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/datanode/SingleTableDataNodeLoader.java
 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/datanode/SingleTableDataNodeLoader.java
index 960d407d7b5..9bcd09cc4ba 100644
--- 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/datanode/SingleTableDataNodeLoader.java
+++ 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/datanode/SingleTableDataNodeLoader.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.singletable.datanode;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
-import 
org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.loader.common.SchemaTableNamesLoader;
+import 
org.apache.shardingsphere.singletable.exception.SingleTablesLoadingException;
 
 import javax.sql.DataSource;
 import java.sql.SQLException;
@@ -87,7 +87,7 @@ public final class SingleTableDataNodeLoader {
         try {
             return SchemaTableNamesLoader.loadSchemaTableNames(databaseName, 
databaseType, dataSource);
         } catch (final SQLException ex) {
-            throw new ShardingSphereConfigurationException("Can not load 
table, databaseName: %s, dataSourceName: %s", databaseName, dataSourceName);
+            throw new SingleTablesLoadingException(databaseName, 
dataSourceName, ex);
         }
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
index 241290507f1..31c8d7d0a03 100644
--- 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
+++ 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
@@ -28,6 +28,6 @@ public final class DropNotEmptySchemaException extends 
ShardingSphereSQLExceptio
     private static final long serialVersionUID = 5285619119572894557L;
     
     public DropNotEmptySchemaException(final String schemaName) {
-        super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 17002, "Can not drop schema 
`%s` because of contains tables", schemaName);
+        super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 17003, "Can not drop schema 
`%s` because of contains tables", schemaName);
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SingleTablesLoadingException.java
similarity index 66%
copy from 
shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
copy to 
shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SingleTablesLoadingException.java
index 241290507f1..882236b6b66 100644
--- 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
+++ 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SingleTablesLoadingException.java
@@ -20,14 +20,16 @@ package org.apache.shardingsphere.singletable.exception;
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.ShardingSphereSQLException;
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
 
+import java.sql.SQLException;
+
 /**
- * Drop not empty schema exception.
+ * Single tables loading exception.
  */
-public final class DropNotEmptySchemaException extends 
ShardingSphereSQLException {
+public final class SingleTablesLoadingException extends 
ShardingSphereSQLException {
     
-    private static final long serialVersionUID = 5285619119572894557L;
+    private static final long serialVersionUID = 698261896187918188L;
     
-    public DropNotEmptySchemaException(final String schemaName) {
-        super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 17002, "Can not drop schema 
`%s` because of contains tables", schemaName);
+    public SingleTablesLoadingException(final String databaseName, final 
String dataSourceName, final SQLException cause) {
+        super(XOpenSQLState.GENERAL_ERROR, 17002, "Can not load table with 
database name `%s` and data source name `%s`, reason is: %s", databaseName, 
dataSourceName, cause.getMessage());
     }
 }

Reply via email to