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 515015e7696 Refactor SQLWrapperException (#35127) 515015e7696 is described below commit 515015e769637052da558f3283cc0992751c3bde Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Fri Apr 4 11:31:40 2025 +0800 Refactor SQLWrapperException (#35127) --- .../exception/core/external/sql/type/wrapper/SQLWrapperException.java | 2 +- .../core/external/sql/type/wrapper/SQLWrapperExceptionTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/wrapper/SQLWrapperException.java b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/wrapper/SQLWrapperException.java index eda8a53db3e..3d9345394ed 100644 --- a/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/wrapper/SQLWrapperException.java +++ b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/wrapper/SQLWrapperException.java @@ -30,6 +30,6 @@ public final class SQLWrapperException extends GenericSQLException { private static final long serialVersionUID = 8983736995662464009L; public SQLWrapperException(final SQLException cause) { - super(XOpenSQLState.GENERAL_ERROR, 5, "Underlying SQL state: " + cause.getSQLState() + ", underlying error code: " + cause.getErrorCode() + ".", cause); + super("Underlying SQL state: " + cause.getSQLState() + ", underlying error code: " + cause.getErrorCode() + ".", XOpenSQLState.GENERAL_ERROR, 5, cause); } } diff --git a/infra/exception/core/src/test/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/wrapper/SQLWrapperExceptionTest.java b/infra/exception/core/src/test/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/wrapper/SQLWrapperExceptionTest.java index efeebd7b04a..3c7600b1557 100644 --- a/infra/exception/core/src/test/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/wrapper/SQLWrapperExceptionTest.java +++ b/infra/exception/core/src/test/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/wrapper/SQLWrapperExceptionTest.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test; import java.sql.SQLException; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; class SQLWrapperExceptionTest { @@ -32,6 +33,6 @@ class SQLWrapperExceptionTest { SQLException actual = new SQLWrapperException(new SQLException("reason", "1", 10)).toSQLException(); assertThat(actual.getSQLState(), is(XOpenSQLState.GENERAL_ERROR.getValue())); assertThat(actual.getErrorCode(), is(30005)); - assertThat(actual.getMessage(), is("Underlying SQL state: 1, underlying error code: 10.")); + assertThat(actual.getMessage(), startsWith("Underlying SQL state: 1, underlying error code: 10.")); } }