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

zhangliang 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 3697e641646 Enable cause for UnknownSQLException and 
SQLWrapperException (#21977)
3697e641646 is described below

commit 3697e6416463520456b39be91b613ab0be1ebb5c
Author: Hongsheng Zhong <[email protected]>
AuthorDate: Thu Nov 10 18:23:51 2022 +0800

    Enable cause for UnknownSQLException and SQLWrapperException (#21977)
---
 .../util/exception/external/sql/type/generic/GenericSQLException.java | 4 ++++
 .../util/exception/external/sql/type/generic/UnknownSQLException.java | 2 +-
 .../util/exception/external/sql/type/wrapper/SQLWrapperException.java | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/generic/GenericSQLException.java
 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/generic/GenericSQLException.java
index a2af72f6553..8145283bff3 100644
--- 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/generic/GenericSQLException.java
+++ 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/generic/GenericSQLException.java
@@ -32,4 +32,8 @@ public abstract class GenericSQLException extends 
ShardingSphereSQLException {
     public GenericSQLException(final SQLState sqlState, final int errorCode, 
final String reason, final Object... messageArguments) {
         super(sqlState, TYPE_OFFSET, errorCode, reason, messageArguments);
     }
+    
+    public GenericSQLException(final String reason, final Exception cause, 
final SQLState sqlState, final int errorCode) {
+        super(reason, cause, sqlState.getValue(), TYPE_OFFSET, errorCode);
+    }
 }
diff --git 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/generic/UnknownSQLException.java
 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/generic/UnknownSQLException.java
index 3a3653bb148..41d3b4a113e 100644
--- 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/generic/UnknownSQLException.java
+++ 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/generic/UnknownSQLException.java
@@ -27,6 +27,6 @@ public final class UnknownSQLException extends 
GenericSQLException {
     private static final long serialVersionUID = -7357918573504734977L;
     
     public UnknownSQLException(final Exception cause) {
-        super(XOpenSQLState.GENERAL_ERROR, 0, "Unknown exception: %s", 
cause.getMessage());
+        super(String.format("Unknown exception: %s", cause.getMessage()), 
cause, XOpenSQLState.GENERAL_ERROR, 0);
     }
 }
diff --git 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/wrapper/SQLWrapperException.java
 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/wrapper/SQLWrapperException.java
index d8465532972..f014b4cc8a1 100644
--- 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/wrapper/SQLWrapperException.java
+++ 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/wrapper/SQLWrapperException.java
@@ -31,6 +31,6 @@ public final class SQLWrapperException extends 
ShardingSphereSQLException {
     private static final int TYPE_OFFSET = 0;
     
     public SQLWrapperException(final SQLException cause) {
-        super(cause.getSQLState(), TYPE_OFFSET, cause.getErrorCode(), 
cause.getMessage());
+        super(cause.getMessage(), cause, cause.getSQLState(), TYPE_OFFSET, 
cause.getErrorCode());
     }
 }

Reply via email to