From fabb8158e946296c489f65d892779e91fb9f0092 Mon Sep 17 00:00:00 2001 From: Jose Medrano Date: Fri, 9 Feb 2024 18:10:33 +0100 Subject: [PATCH] Include statement id in all the error messages (#235) --- .../lst_bench/client/JDBCConnection.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java b/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java index 812f5ae9..4c8a7a43 100644 --- a/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java +++ b/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java @@ -74,7 +74,7 @@ private QueryResult execute(String sqlText, boolean ignoreResults) throws Client } // Log verbosely, if enabled. if (this.showWarnings && LOGGER.isWarnEnabled()) { - logWarnings(s); + LOGGER.warn(createWarningString(s)); } // Return here if successful. return queryResult; @@ -83,20 +83,22 @@ private QueryResult execute(String sqlText, boolean ignoreResults) throws Client String lastErrorMsg = "Query execution (" + this.maxNumRetries - + " retries) unsuccessful; stack trace: " + + " retries) unsuccessful; " + + "Warnings: " + + createWarningString(s) + + "stack trace: " + ExceptionUtils.getStackTrace(e); + + // Log execution error and any pending warnings associated with this statement, useful for + // debugging. if (errorCount == this.maxNumRetries) { - // Log any pending warnings associated with this statement, useful for debugging. - if (LOGGER.isWarnEnabled()) { - logWarnings(s); - } - // Log execution error. LOGGER.error(lastErrorMsg); throw new ClientException(lastErrorMsg); } else { LOGGER.warn(lastErrorMsg); } errorCount++; + } finally { if (s != null) { try { @@ -128,7 +130,7 @@ public void close() throws ClientException { } } - private void logWarnings(Statement s) throws ClientException { + private String createWarningString(Statement s) throws ClientException { List warningList = new ArrayList<>(); if (s != null) { @@ -144,8 +146,6 @@ private void logWarnings(Statement s) throws ClientException { } } - for (String warning : warningList) { - LOGGER.warn(warning); - } + return String.join("; ", warningList); } }