You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2019/05/24 02:30:20 UTC

[incubator-iotdb] branch add_exception_trace created (now dcc215a)

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

jiangtian pushed a change to branch add_exception_trace
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at dcc215a  keep stack trace when logging or throwing an Exception

This branch includes the following new commits:

     new dcc215a  keep stack trace when logging or throwing an Exception

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-iotdb] 01/01: keep stack trace when logging or throwing an Exception

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jiangtian pushed a commit to branch add_exception_trace
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit dcc215a6b47f56cea8212a720076485a66031535
Author: 江天 <jt...@163.com>
AuthorDate: Fri May 24 10:28:28 2019 +0800

    keep stack trace when logging or throwing an Exception
---
 .../org/apache/iotdb/tsfile/hadoop/TSFRecordWriter.java  | 13 +++++--------
 .../apache/iotdb/tsfile/hadoop/example/TsFileHelper.java |  6 ++----
 .../java/cn/edu/thu/tsfile/hadoop/TsFileTestHelper.java  |  6 ++----
 .../apache/iotdb/db/auth/authorizer/BasicAuthorizer.java |  3 +--
 .../db/exception/BufferWriteProcessorException.java      |  2 +-
 .../iotdb/db/exception/FileNodeProcessorException.java   |  2 +-
 .../iotdb/db/exception/OverflowProcessorException.java   |  2 +-
 .../iotdb/db/exception/qp/IllegalASTFormatException.java |  7 +++++++
 .../iotdb/db/exception/qp/LogicalOperatorException.java  |  7 +++++++
 .../iotdb/db/exception/qp/LogicalOptimizeException.java  |  7 +++++++
 .../iotdb/db/exception/qp/QueryProcessorException.java   |  4 ++++
 .../main/java/org/apache/iotdb/db/qp/QueryProcessor.java |  2 +-
 .../iotdb/db/qp/executor/QueryProcessExecutor.java       |  2 +-
 .../iotdb/db/qp/logical/crud/BasicFunctionOperator.java  |  2 +-
 .../apache/iotdb/db/qp/strategy/PhysicalGenerator.java   |  2 +-
 .../db/qp/strategy/optimizer/ConcatPathOptimizer.java    |  9 +++------
 .../org/apache/iotdb/db/service/CloseMergeService.java   |  2 +-
 .../src/main/java/org/apache/iotdb/db/service/IoTDB.java |  9 +++------
 .../java/org/apache/iotdb/db/service/JDBCService.java    |  6 +++---
 .../java/org/apache/iotdb/db/service/JMXService.java     |  5 ++---
 .../main/java/org/apache/iotdb/db/service/Monitor.java   |  3 +--
 .../org/apache/iotdb/db/service/RegisterManager.java     |  2 +-
 .../java/org/apache/iotdb/db/service/TSServiceImpl.java  | 13 +++++++------
 .../java/org/apache/iotdb/db/sql/parse/ParseDriver.java  |  2 +-
 .../main/java/org/apache/iotdb/db/utils/RecordUtils.java |  2 +-
 .../db/writelog/manager/MultiFileLogNodeManager.java     |  9 ++-------
 .../iotdb/db/writelog/node/ExclusiveWriteLogNode.java    |  2 +-
 .../writelog/recover/ExclusiveLogRecoverPerformer.java   | 11 ++++-------
 .../iotdb/db/writelog/replay/ConcreteLogReplayer.java    |  2 +-
 .../main/java/org/apache/iotdb/jdbc/IoTDBConnection.java |  6 +++---
 .../iotdb/tsfile/exception/write/PageException.java      |  8 ++++++++
 .../tsfile/exception/write/WriteProcessException.java    | 16 +++++++++-------
 .../org/apache/iotdb/tsfile/write/chunk/ChunkBuffer.java |  7 +++----
 .../apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java |  7 ++-----
 34 files changed, 98 insertions(+), 90 deletions(-)

diff --git a/hadoop/src/main/java/org/apache/iotdb/tsfile/hadoop/TSFRecordWriter.java b/hadoop/src/main/java/org/apache/iotdb/tsfile/hadoop/TSFRecordWriter.java
index 346d8c9..776f3e6 100644
--- a/hadoop/src/main/java/org/apache/iotdb/tsfile/hadoop/TSFRecordWriter.java
+++ b/hadoop/src/main/java/org/apache/iotdb/tsfile/hadoop/TSFRecordWriter.java
@@ -46,17 +46,15 @@ public class TSFRecordWriter extends RecordWriter<NullWritable, TSRow> {
     try {
       fileSchema = new FileSchema(schema);
     } catch (InvalidJsonSchemaException e) {
-      e.printStackTrace();
-      LOGGER.error("Construct the tsfile schema failed, the reason is {}", e.getMessage());
-      throw new InterruptedException(e.getMessage());
+      throw new InterruptedException(String.format("Construct the tsfile schema failed,"
+          + " the reason is %s", e.getMessage()), e);
     }
 
     HDFSOutputStream hdfsOutputStream = new HDFSOutputStream(path, new Configuration(), false);
     try {
       write = new TsFile(hdfsOutputStream, fileSchema);
     } catch (WriteProcessException e) {
-      e.printStackTrace();
-      throw new IOException(e.getMessage());
+      throw new IOException(e);
     }
   }
 
@@ -66,9 +64,8 @@ public class TSFRecordWriter extends RecordWriter<NullWritable, TSRow> {
     try {
       write.writeRecord(value.getRow());
     } catch (WriteProcessException e) {
-      e.printStackTrace();
-      LOGGER.error("Write tsfile record error, the error message is {}", e.getMessage());
-      throw new InterruptedException(e.getMessage());
+      throw new InterruptedException(String.format("Write tsfile record error,"
+          + " the error message is %s", e.getMessage()), e);
     }
   }
 
diff --git a/hadoop/src/main/java/org/apache/iotdb/tsfile/hadoop/example/TsFileHelper.java b/hadoop/src/main/java/org/apache/iotdb/tsfile/hadoop/example/TsFileHelper.java
index d648029..23dcd48 100644
--- a/hadoop/src/main/java/org/apache/iotdb/tsfile/hadoop/example/TsFileHelper.java
+++ b/hadoop/src/main/java/org/apache/iotdb/tsfile/hadoop/example/TsFileHelper.java
@@ -75,11 +75,9 @@ public class TsFileHelper {
       tsFile.writeLine("root.car.d2,8, s1, 8, s2, 80, s3, 200.8, s4, 0.8");
       tsFile.close();
     } catch (IOException e) {
-      e.printStackTrace();
-      throw new RuntimeException(e.getMessage());
+      throw new RuntimeException(e);
     } catch (WriteProcessException e) {
-      e.printStackTrace();
-      throw new RuntimeException(e.getMessage());
+      throw new RuntimeException(e);
     }
   }
 
diff --git a/hadoop/src/test/java/cn/edu/thu/tsfile/hadoop/TsFileTestHelper.java b/hadoop/src/test/java/cn/edu/thu/tsfile/hadoop/TsFileTestHelper.java
index a80f3cd..a1e832d 100644
--- a/hadoop/src/test/java/cn/edu/thu/tsfile/hadoop/TsFileTestHelper.java
+++ b/hadoop/src/test/java/cn/edu/thu/tsfile/hadoop/TsFileTestHelper.java
@@ -75,11 +75,9 @@ public class TsFileTestHelper {
       tsFile.writeLine("root.car.d2,8, s1, 8, s2, 80, s3, 200.8, s4, 0.8");
       tsFile.close();
     } catch (IOException e) {
-      e.printStackTrace();
-      throw new RuntimeException(e.getMessage());
+      throw new RuntimeException(e);
     } catch (WriteProcessException e) {
-      e.printStackTrace();
-      throw new RuntimeException(e.getMessage());
+      throw new RuntimeException(e);
     }
   }
 
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
index 07f1033..439b3d2 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
@@ -243,8 +243,7 @@ public abstract class BasicAuthorizer implements IAuthorizer, IService {
     try {
       init();
     } catch (AuthException e) {
-      LOGGER.error("Auth authentication error : ", e);
-      throw new StartupException(e.getMessage());
+      throw new StartupException(e);
     }
   }
 
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/BufferWriteProcessorException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/BufferWriteProcessorException.java
index bf6a349..19b2908 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/BufferWriteProcessorException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/BufferWriteProcessorException.java
@@ -35,7 +35,7 @@ public class BufferWriteProcessorException extends ProcessorException {
   }
 
   public BufferWriteProcessorException(Throwable throwable) {
-    super(throwable.getMessage());
+    super(throwable);
   }
 
 }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/FileNodeProcessorException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/FileNodeProcessorException.java
index d3cf362..459430a 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/FileNodeProcessorException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/FileNodeProcessorException.java
@@ -35,7 +35,7 @@ public class FileNodeProcessorException extends ProcessorException {
   }
 
   public FileNodeProcessorException(Throwable throwable) {
-    super(throwable.getMessage());
+    super(throwable);
   }
 
   public FileNodeProcessorException(String msg, Throwable e) {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/OverflowProcessorException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/OverflowProcessorException.java
index 21ac261..77361c0 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/OverflowProcessorException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/OverflowProcessorException.java
@@ -35,7 +35,7 @@ public class OverflowProcessorException extends ProcessorException {
   }
 
   public OverflowProcessorException(Throwable throwable) {
-    super(throwable.getMessage());
+    super(throwable);
   }
 
 }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/IllegalASTFormatException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/IllegalASTFormatException.java
index bb7c359..52624a8 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/IllegalASTFormatException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/IllegalASTFormatException.java
@@ -29,4 +29,11 @@ public class IllegalASTFormatException extends QueryProcessorException {
     super(msg);
   }
 
+  public IllegalASTFormatException(Throwable e) {
+    super(e);
+  }
+
+  public IllegalASTFormatException(String message, Throwable cause) {
+    super(message, cause);
+  }
 }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/LogicalOperatorException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/LogicalOperatorException.java
index 91d9424..f3e3dba 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/LogicalOperatorException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/LogicalOperatorException.java
@@ -29,4 +29,11 @@ public class LogicalOperatorException extends QueryProcessorException {
     super(msg);
   }
 
+  public LogicalOperatorException(Throwable e) {
+    super(e);
+  }
+
+  public LogicalOperatorException(String message, Throwable cause) {
+    super(message, cause);
+  }
 }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/LogicalOptimizeException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/LogicalOptimizeException.java
index df32ce2..239a7fe 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/LogicalOptimizeException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/LogicalOptimizeException.java
@@ -29,4 +29,11 @@ public class LogicalOptimizeException extends LogicalOperatorException {
     super(msg);
   }
 
+  public LogicalOptimizeException(Throwable e) {
+    super(e);
+  }
+
+  public LogicalOptimizeException(String message, Throwable cause) {
+    super(message, cause);
+  }
 }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/QueryProcessorException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/QueryProcessorException.java
index 358227b..516c42b 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/QueryProcessorException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/qp/QueryProcessorException.java
@@ -33,4 +33,8 @@ public class QueryProcessorException extends Exception {
   public QueryProcessorException(Throwable e) {
     super(e);
   }
+
+  public QueryProcessorException(String message, Throwable cause) {
+    super(message, cause);
+  }
 }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/QueryProcessor.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/QueryProcessor.java
index f63514d..74a1abf 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/QueryProcessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/QueryProcessor.java
@@ -108,7 +108,7 @@ public class QueryProcessor {
     } catch (ParseException e) {
       // e.printStackTrace();
       throw new IllegalASTFormatException(
-          "parsing error,statement: " + sqlStr + " .message:" + e.getMessage());
+          "parsing error,statement: " + sqlStr, e);
     }
     return ParseUtils.findRootNonNullToken(astTree);
   }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
index 99476f2..17768aa 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
@@ -110,7 +110,7 @@ public abstract class QueryProcessExecutor implements IQueryProcessExecutor {
       }
       return result;
     } catch (PathErrorException e) {
-      throw new ProcessorException(e.getMessage());
+      throw new ProcessorException(e);
     }
   }
 
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/crud/BasicFunctionOperator.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/crud/BasicFunctionOperator.java
index 1610554..5b8815f 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/crud/BasicFunctionOperator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/logical/crud/BasicFunctionOperator.java
@@ -152,7 +152,7 @@ public class BasicFunctionOperator extends FunctionOperator {
     try {
       ret = new BasicFunctionOperator(this.tokenIntType, path.clone(), value);
     } catch (LogicalOperatorException e) {
-      logger.error("error clone:{}", e.getMessage());
+      logger.error("error clone:", e);
       return null;
     }
     ret.tokenSymbol = tokenSymbol;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
index ff13a2c..ffa0cdf 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
@@ -74,7 +74,7 @@ public class PhysicalGenerator {
               author.getPassWord(), author.getNewPassword(), author.getPrivilegeList(),
               author.getNodeName());
         } catch (AuthException e) {
-          throw new QueryProcessorException(e.getMessage());
+          throw new QueryProcessorException(e);
         }
       case LOADDATA:
         LoadDataOperator loadData = (LoadDataOperator) operator;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/optimizer/ConcatPathOptimizer.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/optimizer/ConcatPathOptimizer.java
index 9736f7c..bdac149 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/optimizer/ConcatPathOptimizer.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/optimizer/ConcatPathOptimizer.java
@@ -306,8 +306,7 @@ public class ConcatPathOptimizer implements ILogicalOptimizer {
             new BasicFunctionOperator(operator.getTokenIntType(), noStarPaths.get(i),
                 ((BasicFunctionOperator) operator).getValue()));
       } catch (LogicalOperatorException e) {
-        LOG.error("meet error while adding child operator to current node.", e);
-        throw new LogicalOptimizeException(e.getMessage());
+        throw new LogicalOptimizeException(e);
       }
     }
     return filterTwoFolkTree;
@@ -336,8 +335,7 @@ public class ConcatPathOptimizer implements ILogicalOptimizer {
         retPaths.add(new Path(pathStr));
       }
     } catch (PathErrorException e) {
-      LOG.error("meet error while removing star.", e);
-      throw new LogicalOptimizeException("error when remove star: " + e.getMessage());
+      throw new LogicalOptimizeException("error when remove star: ", e);
     }
     return retPaths;
   }
@@ -356,8 +354,7 @@ public class ConcatPathOptimizer implements ILogicalOptimizer {
           }
         }
       } catch (PathErrorException e) {
-        LOG.error("meet error while removing star.", e);
-        throw new LogicalOptimizeException("error when remove star: " + e.getMessage());
+        throw new LogicalOptimizeException("error when remove star: ", e);
       }
     }
     if (retPaths.isEmpty()) {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/CloseMergeService.java b/iotdb/src/main/java/org/apache/iotdb/db/service/CloseMergeService.java
index 0915cd3..1f0b117 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/CloseMergeService.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/CloseMergeService.java
@@ -122,7 +122,7 @@ public class CloseMergeService implements IService {
           .format("Failed to start %s because of %s", this.getID().getName(),
               e.getMessage());
       LOGGER.error(errorMessage);
-      throw new StartupException(errorMessage);
+      throw new StartupException(errorMessage, e);
     }
   }
 
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/IoTDB.java b/iotdb/src/main/java/org/apache/iotdb/db/service/IoTDB.java
index d9a1938..a7cf296 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/IoTDB.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/IoTDB.java
@@ -61,8 +61,8 @@ public class IoTDB implements IoTDBMBean {
       checks.verify();
     } catch (StartupException e) {
       // TODO: what are some checks
-      LOGGER.error("{}: failed to start because some checks failed. {}",
-          IoTDBConstant.GLOBAL_DB_NAME, e.getMessage());
+      LOGGER.error("{}: failed to start because some checks failed. ",
+          IoTDBConstant.GLOBAL_DB_NAME, e);
       return;
     }
     try {
@@ -86,10 +86,7 @@ public class IoTDB implements IoTDBMBean {
     try {
       systemDataRecovery();
     } catch (RecoverException e) {
-      String errorMessage = String.format("Failed to recover system data because of %s",
-          e.getMessage());
-      LOGGER.error(errorMessage);
-      throw new StartupException(errorMessage);
+      throw new StartupException("Fail to recover data", e);
     }
     // When registering statMonitor, we should start recovering some statistics
     // with latest values stored
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/JDBCService.java b/iotdb/src/main/java/org/apache/iotdb/db/service/JDBCService.java
index 1326e23..ae222c7 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/JDBCService.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/JDBCService.java
@@ -129,12 +129,12 @@ public class JDBCService implements JDBCServiceMBean, IService {
       jdbcServiceThread.setName(ThreadName.JDBC_SERVICE.getName());
       jdbcServiceThread.start();
       startLatch.await();
-    } catch (IOException | InterruptedException | ClassNotFoundException | IllegalAccessException | InstantiationException e) {
+    } catch (IOException | InterruptedException | ClassNotFoundException |
+        IllegalAccessException | InstantiationException e) {
       String errorMessage = String
           .format("Failed to start %s because of %s", this.getID().getName(),
               e.getMessage());
-      LOGGER.error(errorMessage);
-      throw new StartupException(errorMessage);
+      throw new StartupException(errorMessage, e);
     }
 
     LOGGER.info("{}: start {} successfully, listening on ip {} port {}", IoTDBConstant.GLOBAL_DB_NAME,
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/JMXService.java b/iotdb/src/main/java/org/apache/iotdb/db/service/JMXService.java
index 74e5691..9ddc9da 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/JMXService.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/JMXService.java
@@ -138,8 +138,7 @@ public class JMXService implements IService {
       String errorMessage = String
           .format("Failed to start %s because of %s", this.getID().getName(),
               e.getMessage());
-      LOGGER.error(errorMessage);
-      throw new StartupException(errorMessage);
+      throw new StartupException(errorMessage, e);
     }
   }
 
@@ -151,7 +150,7 @@ public class JMXService implements IService {
         LOGGER.info("{}: close {} successfully", IoTDBConstant.GLOBAL_DB_NAME,
             this.getID().getName());
       } catch (IOException e) {
-        LOGGER.error("Failed to stop {} because of {}", this.getID().getName(), e.getMessage());
+        LOGGER.error("Failed to stop {} because of: ", this.getID().getName(), e);
       }
     }
   }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/Monitor.java b/iotdb/src/main/java/org/apache/iotdb/db/service/Monitor.java
index 6348f50..53fb90f 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/Monitor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/Monitor.java
@@ -148,8 +148,7 @@ public class Monitor implements MonitorMBean, IService {
       String errorMessage = String
           .format("Failed to start %s because of %s", this.getID().getName(),
               e.getMessage());
-      LOGGER.error(errorMessage);
-      throw new StartupException(errorMessage);
+      throw new StartupException(errorMessage, e);
     }
   }
 
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/RegisterManager.java b/iotdb/src/main/java/org/apache/iotdb/db/service/RegisterManager.java
index 5a9f327..cec2233 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/RegisterManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/RegisterManager.java
@@ -55,7 +55,7 @@ public class RegisterManager {
       try {
         service.stop();
       } catch (Exception e) {
-        LOGGER.error("Failed to stop {} because {}", service.getID().getName(), e.getMessage());
+        LOGGER.error("Failed to stop {} because:", service.getID().getName(), e);
       }
     }
     iServices.clear();
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/iotdb/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index b02f1c2..592b009 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -193,7 +193,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
 
       clearAllStatusForCurrentRequest();
     } catch (Exception e) {
-      LOGGER.error("Error in closeOperation : {}", e.getMessage());
+      LOGGER.error("Error in closeOperation : ", e);
     }
     return new TSCloseOperationResp(new TS_Status(TS_StatusCode.SUCCESS_STATUS));
   }
@@ -465,6 +465,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
               "Fail to generate physcial plan and execute for statement "
                   + "%s beacuse %s",
               statement, e.getMessage());
+          LOGGER.warn("Error occurred when executing {}", statement, e);
           result.add(Statement.EXECUTE_FAILED);
           isAllSuccessful = false;
           batchErrorMessage = errMessage;
@@ -506,6 +507,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
               "Execute set consistency level successfully");
         }
       } catch (Exception e) {
+        LOGGER.error("Error occurred when executing statement {}", statement, e);
         return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
       }
 
@@ -514,11 +516,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         physicalPlan = processor.parseSQLToPhysicalPlan(statement, zoneIds.get());
         physicalPlan.setProposer(username.get());
       } catch (IllegalASTFormatException e) {
-        LOGGER.debug("meet error while parsing SQL to physical plan: {}", e.getMessage());
+        LOGGER.debug("meet error while parsing SQL to physical plan: ", e);
         return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
             "Statement format is not right:" + e.getMessage());
       } catch (NullPointerException e) {
-        LOGGER.error("meet error while parsing SQL to physical plan.", e);
+        LOGGER.error("meet error while parsing SQL to physical plan: ", e);
         return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Statement is not allowed");
       }
       if (physicalPlan.isQuery()) {
@@ -527,8 +529,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return executeUpdateStatement(physicalPlan);
       }
     } catch (Exception e) {
-      LOGGER.info("meet error: {}  while executing statement: {}", e.getMessage(),
-          req.getStatement());
+      LOGGER.info("meet error while executing statement: {}", req.getStatement(), e);
       return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
     }
   }
@@ -756,7 +757,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
     try {
       execRet = executeNonQuery(plan);
     } catch (ProcessorException e) {
-      LOGGER.debug("meet error while processing non-query. {}", e.getMessage());
+      LOGGER.debug("meet error while processing non-query. ", e);
       return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
     }
     TS_StatusCode statusCode = execRet ? TS_StatusCode.SUCCESS_STATUS : TS_StatusCode.ERROR_STATUS;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/sql/parse/ParseDriver.java b/iotdb/src/main/java/org/apache/iotdb/db/sql/parse/ParseDriver.java
index 6491d4b..9be7d05 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/sql/parse/ParseDriver.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/sql/parse/ParseDriver.java
@@ -97,7 +97,7 @@ public class ParseDriver {
 
       r = parser.statement();
     } catch (RecognitionException e) {
-      LOG.trace("meet error: {} while parsing statement: {}", e.getMessage(), command);
+      LOG.trace("meet error while parsing statement: {}", command, e);
     }
 
     if (lexer.getErrors().isEmpty() && parser.errors.isEmpty()) {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/utils/RecordUtils.java b/iotdb/src/main/java/org/apache/iotdb/db/utils/RecordUtils.java
index a77a294..5487ff2 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/utils/RecordUtils.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/utils/RecordUtils.java
@@ -106,7 +106,7 @@ public class RecordUtils {
               break;
           }
         } catch (NumberFormatException e) {
-          LOG.warn("parsing measurement meets error, omit it: {}", e.getMessage());
+          LOG.warn("parsing measurement {} meets error, omit it: ", str, e);
         }
       }
     }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
index 8bf9fb9..bf1e816 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
@@ -137,12 +137,7 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
     nodeList.addAll(nodeMap.values());
     nodeList.sort(null);
     for (WriteLogNode node : nodeList) {
-      try {
-        node.recover();
-      } catch (RecoverException e) {
-        logger.error("{} failed to recover because {}", node.toString(), e.getMessage());
-        throw e;
-      }
+      node.recover();
     }
   }
 
@@ -228,7 +223,7 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
       String errorMessage = String
           .format("Failed to start %s because of %s", this.getID().getName(),
               e.getMessage());
-      throw new StartupException(errorMessage);
+      throw new StartupException(errorMessage, e);
     }
   }
 
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
index d8e99ae..1b2682f 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
@@ -124,7 +124,7 @@ public class ExclusiveWriteLogNode implements WriteLogNode, Comparable<Exclusive
       this.currentFileWriter.close();
       logger.debug("Log node {} closed successfully", identifier);
     } catch (IOException e) {
-      logger.error("Cannot close log node {} because {}", identifier, e.getMessage());
+      logger.error("Cannot close log node {} because:", identifier, e);
     }
     unlockForForceOther();
     unlockForOther();
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/recover/ExclusiveLogRecoverPerformer.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/recover/ExclusiveLogRecoverPerformer.java
index 15e88dd..495ce8e 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/recover/ExclusiveLogRecoverPerformer.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/recover/ExclusiveLogRecoverPerformer.java
@@ -246,10 +246,8 @@ public class ExclusiveLogRecoverPerformer implements RecoverPerformer {
         FileUtils.copyFile(recoverProcessorStoreFile, new File(processorStoreFilePath));
       }
     } catch (Exception e) {
-      logger.error("Log node {} cannot recover processor file, because{}",
-          writeLogNode.getLogDirectory(),
-          e.getMessage());
-      throw new RecoverException("Cannot recover processor file, recovery aborted.");
+      throw new RecoverException(String.format("Log node %s cannot recover processor file,"
+          + " recovery aborted.", writeLogNode.getLogDirectory()), e);
     }
 
     fileNodeRecoverPerformer.recover();
@@ -316,9 +314,8 @@ public class ExclusiveLogRecoverPerformer implements RecoverPerformer {
     try {
       FileNodeManager.getInstance().closeOneFileNode(writeLogNode.getFileNodeName());
     } catch (FileNodeManagerException e) {
-      logger.error("Log node {} cannot perform flush after replaying logs! Because {}",
-          writeLogNode.getIdentifier(), e.getMessage());
-      throw new RecoverException(e);
+      throw new RecoverException(String.format("Log node %s cannot perform flush after replaying logs! Because %s",
+          writeLogNode.getIdentifier(), e.getMessage()), e);
     }
     currStage = CLEAN_UP;
     setFlag(REPLAY_LOG);
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/replay/ConcreteLogReplayer.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/replay/ConcreteLogReplayer.java
index 6573884..2142303 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/replay/ConcreteLogReplayer.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/replay/ConcreteLogReplayer.java
@@ -57,7 +57,7 @@ public class ConcreteLogReplayer implements LogReplayer {
       }
     } catch (Exception e) {
       throw new ProcessorException(
-          String.format("Cannot replay log %s, because %s", plan.toString(), e.getMessage()));
+          String.format("Cannot replay log %s, because %s", plan.toString(), e.getMessage()), e);
     }
   }
 
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
index 815725a..e94b926 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
@@ -410,7 +410,7 @@ public class IoTDBConnection implements Connection {
     try {
       transport.getSocket().setKeepAlive(true);
     } catch (SocketException e) {
-      logger.error("Cannot set socket keep alive because: " + e.getMessage());
+      logger.error("Cannot set socket keep alive because: ", e);
     }
     if (!transport.isOpen()) {
       transport.open();
@@ -447,8 +447,8 @@ public class IoTDBConnection implements Connection {
       }
 
     } catch (TException e) {
-      throw new SQLException(String.format("Can not establish connection with %s. because %s",
-          params.getJdbcUriString(), e.getMessage()));
+      throw new SQLException(String.format("Can not establish connection with %s.",
+          params.getJdbcUriString()), e);
     }
     isClosed = false;
   }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/write/PageException.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/write/PageException.java
index c38a25b..eee08ec 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/write/PageException.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/write/PageException.java
@@ -28,4 +28,12 @@ public class PageException extends WriteProcessException {
   public PageException(String msg) {
     super(msg);
   }
+
+  public PageException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public PageException(Throwable cause) {
+    super(cause);
+  }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/write/WriteProcessException.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/write/WriteProcessException.java
index 8b50038..dcadd01 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/write/WriteProcessException.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/write/WriteProcessException.java
@@ -26,15 +26,17 @@ package org.apache.iotdb.tsfile.exception.write;
 public class WriteProcessException extends Exception {
 
   private static final long serialVersionUID = -2664638061585302767L;
-  private final String errMsg;
 
-  public WriteProcessException(String msg) {
-    super(msg);
-    this.errMsg = msg;
+
+  public WriteProcessException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public WriteProcessException(String message) {
+    super(message);
   }
 
-  @Override
-  public String getMessage() {
-    return errMsg;
+  public WriteProcessException(Throwable cause) {
+    super(cause);
   }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkBuffer.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkBuffer.java
index 8b0a5f8..4f452a6 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkBuffer.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkBuffer.java
@@ -113,7 +113,7 @@ public class ChunkBuffer {
         compressedSize = compressor
             .compress(data.array(), data.position(), data.remaining(), compressedBytes);
       } catch (IOException e) {
-        throw new PageException("Error when writing a page, " + e.getMessage());
+        throw new PageException(e);
       }
     }
 
@@ -133,7 +133,7 @@ public class ChunkBuffer {
     } catch (IOException e) {
       resetTimeStamp();
       throw new PageException(
-          "IO Exception in writeDataPageHeader,ignore this page,error message:" + e.getMessage());
+          "IO Exception in writeDataPageHeader,ignore this page", e);
     }
 
     // update data point num
@@ -153,8 +153,7 @@ public class ChunkBuffer {
       }
       LOG.debug("start to flush a page data into buffer, buffer position {} ", pageBuffer.size());
     } catch (IOException e) {
-      throw new PageException(
-          "meet IO Exception in buffer append,but we cannot understand it:" + e.getMessage());
+      throw new PageException(e);
     }
     return headerSize + uncompressedSize;
   }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
index cefc065..1aa9932 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
@@ -244,13 +244,10 @@ public class ChunkWriterImpl implements IChunkWriter {
       // update statistics of this series
       this.chunkStatistics.mergeStatistics(this.pageStatistics);
     } catch (IOException e) {
-      LOG.error("meet error in dataPageWriter.getUncompressedBytes(),ignore this page, {}",
-          e.getMessage());
+      LOG.error("meet error in dataPageWriter.getUncompressedBytes(),ignore this page:", e);
     } catch (PageException e) {
       LOG.error(
-          "meet error in chunkBuffer.writePageHeaderAndDataIntoBuff, ignore this page, "
-              + "error message:{}",
-          e.getMessage());
+          "meet error in chunkBuffer.writePageHeaderAndDataIntoBuff, ignore this page:", e);
     } finally {
       // clear start time stamp for next initializing
       minTimestamp = -1;