Skip to content

Commit

Permalink
Include statement id in all the error messages (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
netonjm authored Feb 9, 2024
1 parent a21f1d5 commit fabb815
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -128,7 +130,7 @@ public void close() throws ClientException {
}
}

private void logWarnings(Statement s) throws ClientException {
private String createWarningString(Statement s) throws ClientException {
List<String> warningList = new ArrayList<>();

if (s != null) {
Expand All @@ -144,8 +146,6 @@ private void logWarnings(Statement s) throws ClientException {
}
}

for (String warning : warningList) {
LOGGER.warn(warning);
}
return String.join("; ", warningList);
}
}

0 comments on commit fabb815

Please sign in to comment.