This is an automated email from the ASF dual-hosted git repository.

gaojun2048 pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new d0c6217f2 [Improve][Connector-V2] The log outputs detailed exception 
stack information (#3805)
d0c6217f2 is described below

commit d0c6217f27103ed90eb62d56e2a8e0e6f74b1f51
Author: lightzhao <[email protected]>
AuthorDate: Wed Dec 28 20:17:05 2022 +0800

    [Improve][Connector-V2] The log outputs detailed exception stack 
information (#3805)
    
    * The log outputs detailed exception stack information
---
 .../org/apache/seatunnel/common/utils/FileUtils.java   | 18 ++++++++++--------
 .../seatunnel/cassandra/sink/CassandraSinkWriter.java  |  2 +-
 .../seatunnel/file/sink/writer/TextWriteStrategy.java  |  3 +--
 .../hive/commit/HiveSinkAggregatedCommitter.java       |  4 ++--
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git 
a/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java
 
b/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java
index 58f95e662..d1c301f2b 100644
--- 
a/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java
+++ 
b/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java
@@ -17,6 +17,9 @@
 
 package org.apache.seatunnel.common.utils;
 
+import org.apache.seatunnel.common.exception.CommonErrorCode;
+import org.apache.seatunnel.common.exception.SeaTunnelRuntimeException;
+
 import lombok.NonNull;
 import lombok.extern.slf4j.Slf4j;
 
@@ -46,7 +49,7 @@ public class FileUtils {
                     try {
                         return path.toUri().toURL();
                     } catch (MalformedURLException e) {
-                        throw new SeaTunnelException(e);
+                        throw new 
SeaTunnelRuntimeException(CommonErrorCode.REFLECT_CLASS_OPERATION_FAILED, e);
                     }
                 }).collect(Collectors.toList());
         }
@@ -57,8 +60,7 @@ public class FileUtils {
             byte[] bytes = Files.readAllBytes(path);
             return new String(bytes);
         } catch (IOException e) {
-            log.error(ExceptionUtils.getMessage(e));
-            throw new SeaTunnelException(e);
+            throw new 
SeaTunnelRuntimeException(CommonErrorCode.FILE_OPERATION_FAILED, 
ExceptionUtils.getMessage(e));
         }
     }
 
@@ -69,8 +71,7 @@ public class FileUtils {
             ps = new PrintStream(new FileOutputStream(file));
             ps.println(str);
         } catch (FileNotFoundException e) {
-            log.error(ExceptionUtils.getMessage(e));
-            throw new SeaTunnelException(e);
+            throw new 
SeaTunnelRuntimeException(CommonErrorCode.FILE_OPERATION_FAILED, 
ExceptionUtils.getMessage(e), e);
         } finally {
             if (ps != null) {
                 ps.close();
@@ -112,7 +113,8 @@ public class FileUtils {
         try {
             return Files.lines(Paths.get(filePath)).count();
         } catch (IOException e) {
-            throw new SeaTunnelException(String.format("get file[%s] line 
error", filePath), e);
+            throw new 
SeaTunnelRuntimeException(CommonErrorCode.FILE_OPERATION_FAILED,
+                    String.format("get file[%s] line error", filePath), e);
         }
     }
 
@@ -178,8 +180,8 @@ public class FileUtils {
             file.delete();
 
         } catch (Exception e) {
-            log.error("delete file [" + file.getPath() + "] error");
-            throw new SeaTunnelException(e);
+            String errorMsg = String.format("Delete file [%s] failed", 
file.getPath());
+            throw new 
SeaTunnelRuntimeException(CommonErrorCode.FILE_OPERATION_FAILED, errorMsg, e);
         }
     }
 }
diff --git 
a/seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/sink/CassandraSinkWriter.java
 
b/seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/sink/CassandraSinkWriter.java
index ca069b684..7965b8443 100644
--- 
a/seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/sink/CassandraSinkWriter.java
+++ 
b/seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/sink/CassandraSinkWriter.java
@@ -96,7 +96,7 @@ public class CassandraSinkWriter extends 
AbstractSinkWriter<SeaTunnelRow, Void>
             try {
                 
this.session.execute(this.batchStatement.addAll(boundStatementList));
             } catch (Exception e) {
-                log.error("Batch insert error,Try inserting one by one!");
+                log.error("Batch insert error,Try inserting one by one!", e);
                 for (BoundStatement statement : boundStatementList) {
                     this.session.execute(statement);
                 }
diff --git 
a/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/writer/TextWriteStrategy.java
 
b/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/writer/TextWriteStrategy.java
index 7a6b6b329..ebd491b08 100644
--- 
a/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/writer/TextWriteStrategy.java
+++ 
b/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/writer/TextWriteStrategy.java
@@ -98,7 +98,7 @@ public class TextWriteStrategy extends AbstractWriteStrategy {
                 try {
                     value.close();
                 } catch (IOException e) {
-                    log.error("error when close output stream {}", key);
+                    log.error("error when close output stream {}", key, e);
                 }
             }
             needMoveFiles.put(key, getTargetLocation(key));
@@ -115,7 +115,6 @@ public class TextWriteStrategy extends 
AbstractWriteStrategy {
                 beingWrittenOutputStream.put(filePath, fsDataOutputStream);
                 isFirstWrite.put(filePath, true);
             } catch (IOException e) {
-                log.error("can not get output file stream");
                 throw new 
FileConnectorException(CommonErrorCode.FILE_OPERATION_FAILED,
                         String.format("Open file output stream [%s] failed", 
filePath), e);
             }
diff --git 
a/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/commit/HiveSinkAggregatedCommitter.java
 
b/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/commit/HiveSinkAggregatedCommitter.java
index b6c22e5f3..b3471da78 100644
--- 
a/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/commit/HiveSinkAggregatedCommitter.java
+++ 
b/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/commit/HiveSinkAggregatedCommitter.java
@@ -60,7 +60,7 @@ public class HiveSinkAggregatedCommitter extends 
FileSinkAggregatedCommitter {
                     hiveMetaStore.addPartitions(dbName, tableName, partitions);
                     log.info("Add these partitions {}", partitions);
                 } catch (TException e) {
-                    log.error("Failed to add these partitions {}", partitions);
+                    log.error("Failed to add these partitions {}", partitions, 
e);
                     errorCommitInfos.add(aggregatedCommitInfo);
                 }
             }
@@ -82,7 +82,7 @@ public class HiveSinkAggregatedCommitter extends 
FileSinkAggregatedCommitter {
                 hiveMetaStore.dropPartitions(dbName, tableName, partitions);
                 log.info("Remove these partitions {}", partitions);
             } catch (TException e) {
-                log.error("Failed to remove these partitions {}", partitions);
+                log.error("Failed to remove these partitions {}", partitions, 
e);
             }
         }
         hiveMetaStore.close();

Reply via email to