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 f4831b36821 Add DatetimeLoadingException (#20335)
f4831b36821 is described below

commit f4831b36821775756a985f6675bf7f72fd8cb689
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Aug 21 20:27:49 2022 +0800

    Add DatetimeLoadingException (#20335)
---
 .../user-manual/error-code/sql-error-code.cn.md    |  1 +
 .../user-manual/error-code/sql-error-code.en.md    |  1 +
 .../datetime/database/DatabaseDatetimeService.java |  4 +--
 .../exception/DatetimeLoadingException.java        | 35 ++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 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 a74821ba293..10d9a53b077 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
@@ -18,6 +18,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 44000     | 13000       | SQL check failed, error message: %s |
 | HY000     | 14000       | The table \`%s\` of schema \`%s\` is locked |
 | HY000     | 14001       | The table \`%s\` of schema \`%s\` lock wait 
timeout of %s ms exceeded |
+| HY000     | 14010       | Load datetime from database failed, reason: %s |
 | HY000     | 15000       | Work ID assigned failed, which can not exceed 1024 
|
 | HY000     | 16000       | Can not find pipeline job \`%s\` |
 | HY000     | 16001       | Failed to get DDL for table \`%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 a1ce078aac4..a6dbbb70256 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
@@ -18,6 +18,7 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 44000     | 13000       | SQL check failed, error message: %s |
 | HY000     | 14000       | The table \`%s\` of schema \`%s\` is locked |
 | HY000     | 14001       | The table \`%s\` of schema \`%s\` lock wait 
timeout of %s ms exceeded |
+| HY000     | 14010       | Load datetime from database failed, reason: %s |
 | HY000     | 15000       | Work ID assigned failed, which can not exceed 1024 
|
 | HY000     | 16000       | Can not find pipeline job \`%s\` |
 | HY000     | 16001       | Failed to get DDL for table \`%s\` |
diff --git 
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
 
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
index 89a91d4807e..6946c6496a4 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
@@ -18,9 +18,9 @@
 package org.apache.shardingsphere.datetime.database;
 
 import 
org.apache.shardingsphere.datetime.database.config.DatabaseDatetimeServiceConfiguration;
+import 
org.apache.shardingsphere.datetime.database.exception.DatetimeLoadingException;
 import 
org.apache.shardingsphere.datetime.database.provider.DatetimeLoadingSQLProviderFactory;
 import org.apache.shardingsphere.infra.datetime.DatetimeService;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 
 import javax.sql.DataSource;
 import java.sql.Connection;
@@ -41,7 +41,7 @@ public final class DatabaseDatetimeService implements 
DatetimeService {
         try {
             return loadDatetime(timeServiceConfig.getDataSource(), 
DatetimeLoadingSQLProviderFactory.getInstance(timeServiceConfig.getDatabaseType()).getDatetimeLoadingSQL());
         } catch (final SQLException ex) {
-            throw new ShardingSphereException("Load datetime from database 
error!", ex);
+            throw new DatetimeLoadingException(ex);
         }
     }
     
diff --git 
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/DatetimeLoadingException.java
 
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/DatetimeLoadingException.java
new file mode 100644
index 00000000000..5286befcd78
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/DatetimeLoadingException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.datetime.database.exception;
+
+import 
org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
+import 
org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;
+
+import java.sql.SQLException;
+
+/**
+ * Datetime loading exception.
+ */
+public final class DatetimeLoadingException extends ShardingSphereSQLException 
{
+    
+    private static final long serialVersionUID = 7844267165522132993L;
+    
+    public DatetimeLoadingException(final SQLException cause) {
+        super(XOpenSQLState.GENERAL_ERROR, 10000, "Load datetime from database 
failed, reason: %s", cause.getMessage());
+    }
+}

Reply via email to