From 32e152dc197d330fdcfca765cd97bbb5bcd9c4b0 Mon Sep 17 00:00:00 2001 From: joker1007 Date: Thu, 7 Sep 2023 12:41:55 +0900 Subject: [PATCH] Add logging to avoid loss of information when exception changes during retries --- .../output/jdbc/AbstractJdbcOutputPlugin.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/AbstractJdbcOutputPlugin.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/AbstractJdbcOutputPlugin.java index af8a4ba8..15d93595 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/AbstractJdbcOutputPlugin.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/AbstractJdbcOutputPlugin.java @@ -1369,7 +1369,18 @@ public void onGiveup(Exception firstException, Exception lastException) SQLException ex = (SQLException) firstException; String sqlState = ex.getSQLState(); int errorCode = ex.getErrorCode(); - logger.error("{} ({}:{})", errorMessage, errorCode, sqlState); + logger.error("{} (first exception:{SQLState={}, ErrorCode={}})", errorMessage, errorCode, sqlState, ex); + } else { + logger.error("{} (first exception)", errorMessage, firstException); + } + + if (lastException instanceof SQLException) { + SQLException ex = (SQLException) lastException; + String sqlState = ex.getSQLState(); + int errorCode = ex.getErrorCode(); + logger.error("{} (last exception:{SQLState={}, ErrorCode={}})", errorMessage, errorCode, sqlState, ex); + } else { + logger.error("{} (last exception)", errorMessage, lastException); } }