Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,12 @@ <T> T withRetries(Operation<T> operation) throws SQLException {
if (timeLeft == 0 || attempts >= maxAttempts || !isRetryable(sqlException)) {
String exceptionMessage =
String.format(
"Failed due to %s, after , %s attempts and %s milliseconds",
sqlException.getMessage(), attempts, maxDuration);
"Failed due to '%s' (error code %d, sql-state '%s'), after %s attempts and %s milliseconds",
sqlException.getMessage(),
sqlException.getErrorCode(),
sqlException.getSQLState(),
attempts,
maxDuration);
throw new SQLException(
exceptionMessage, sqlException.getSQLState(), sqlException.getErrorCode(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void testRetryAttemptsExceedMaxRetries() throws SQLException {
SQLException thrown =
assertThrows(SQLException.class, () -> datasourceOperations.withRetries(mockOperation));
assertEquals(
"Failed due to Retryable error, after , 2 attempts and 1000 milliseconds",
"Failed due to 'Retryable error' (error code 0, sql-state '40001'), after 2 attempts and 1000 milliseconds",
thrown.getMessage());
verify(mockOperation, times(2)).execute(); // Tried twice, then threw
}
Expand Down Expand Up @@ -213,7 +213,7 @@ void testNonRetryableSQLException() throws SQLException {
SQLException thrown =
assertThrows(SQLException.class, () -> datasourceOperations.withRetries(mockOperation));
assertEquals(
"Failed due to NonRetryable error, after , 1 attempts and 1000 milliseconds",
"Failed due to 'NonRetryable error' (error code 0, sql-state 'null'), after 1 attempts and 1000 milliseconds",
thrown.getMessage());
verify(mockOperation, times(1)).execute(); // Should not retry
}
Expand Down