Skip to content

Commit

Permalink
Include statement id's for all the error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
netonjm committed Feb 9, 2024
1 parent a21f1d5 commit 50fe1df
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 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);
logWarnings(s, false);
}
// Return here if successful.
return queryResult;
Expand All @@ -85,11 +85,14 @@ private QueryResult execute(String sqlText, boolean ignoreResults) throws Client
+ this.maxNumRetries
+ " retries) unsuccessful; stack trace: "
+ ExceptionUtils.getStackTrace(e);
if (errorCount == this.maxNumRetries) {
// Log any pending warnings associated with this statement, useful for debugging.
if (LOGGER.isWarnEnabled()) {
logWarnings(s);
}

// Log any pending warnings associated with this statement, useful for debugging.
boolean logAsError = errorCount == this.maxNumRetries;
if (LOGGER.isWarnEnabled()) {
logWarnings(s, logAsError);
}

if (logAsError) {
// Log execution error.
LOGGER.error(lastErrorMsg);
throw new ClientException(lastErrorMsg);
Expand Down Expand Up @@ -128,7 +131,7 @@ public void close() throws ClientException {
}
}

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

if (s != null) {
Expand All @@ -145,7 +148,11 @@ private void logWarnings(Statement s) throws ClientException {
}

for (String warning : warningList) {
LOGGER.warn(warning);
if (logAsError) {
LOGGER.error(warning);
} else {
LOGGER.warn(warning);
}
}
}
}

0 comments on commit 50fe1df

Please sign in to comment.