From cf4ae9438f06823d4adf06315ce7018d10aac6ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Mon, 5 Sep 2016 13:41:58 +0200 Subject: [PATCH] improve DbTester SQL utility methods exception stacktrace --- sonar-db/src/test/java/org/sonar/db/DbTester.java | 7 +++++++ 1 file changed, 7 insertions(+) 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); } -- 2.39.5