Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include statement id in all the error messages #235

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading