From: Sébastien Lesaint Date: Mon, 5 Sep 2016 11:41:58 +0000 (+0200) Subject: improve DbTester SQL utility methods exception stacktrace X-Git-Tag: 6.1-RC1~167 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cf4ae9438f06823d4adf06315ce7018d10aac6ce;p=sonarqube.git improve DbTester SQL utility methods exception stacktrace --- diff --git a/sonar-db/src/test/java/org/sonar/db/DbTester.java b/sonar-db/src/test/java/org/sonar/db/DbTester.java index e93f4dd21af..b2b6f08716d 100644 --- a/sonar-db/src/test/java/org/sonar/db/DbTester.java +++ b/sonar-db/src/test/java/org/sonar/db/DbTester.java @@ -135,6 +135,13 @@ public class DbTester extends ExternalResource { public void executeUpdateSql(String sql, Object... params) { try (Connection connection = getConnection()) { new QueryRunner().update(connection, sql, params); + } catch (SQLException e) { + SQLException nextException = e.getNextException(); + if (nextException != null) { + throw new IllegalStateException("Fail to execute sql: " + sql, + new SQLException(e.getMessage(), nextException.getSQLState(), nextException.getErrorCode(), nextException)); + } + throw new IllegalStateException("Fail to execute sql: " + sql, e); } catch (Exception e) { throw new IllegalStateException("Fail to execute sql: " + sql, e); }