Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix SQLServerException wrapped by another SQLServerException #213

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ private void checkClosed() throws SQLServerException {
}
}
}
catch (SQLServerException e) {
throw e;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add one line comment like SQLServerException should not again wrapped by SQLServerException

}
catch (SQLException e) {
SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;

import com.microsoft.sqlserver.jdbc.SQLServerException;
import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.util.RandomUtil;

Expand Down Expand Up @@ -54,4 +55,21 @@ public void testParameterMetaDataWrapper() throws SQLException {
}
}

/**
* Test SQLServerException is not wrapped with another SQLServerException.
*
* @throws SQLException
*/
@Test
public void testSQLServerExceptionNotWrapped() throws SQLException {
try (Connection con = DriverManager.getConnection(connectionString);
PreparedStatement pstmt = connection.prepareStatement("invalid query :)");) {

pstmt.getParameterMetaData();
}
catch (SQLServerException e) {
assertTrue(!e.getMessage().contains("com.microsoft.sqlserver.jdbc.SQLServerException"),
"SQLServerException should not be wrapped by another SQLServerException.");
}
}
}