开发者

Extracting meaningful information from stacktrace

开发者 https://www.devze.com 2023-03-15 20:23 出处:网络
How can we get meaningful information from stack trace generated, eg the stack trace generated开发者_如何学编程 by following catch block

How can we get meaningful information from stack trace generated, eg the stack trace generated开发者_如何学编程 by following catch block

try{


}catch(Exception e){
    e.printStackTrace();
}

Kindly reply.Thanks in advance.


There is a very good answer I found in another forum regarding this. Read this, then this and definitely this.


I find the following pieces of the stack trace meaningful:

  1. The line in your own class where the exception occurred: this will give you an indication if you're possibly making a mistake, e.g. incorrect pre-conditions or usage of a 3rd party API.
  2. The root cause (in the case of nested exceptions): e.g. you're trying to connect to a database on a non-existent remote server -- the exception will be some SqlException, but the root cause will point to an incorrect host name, for instance.
0

精彩评论

暂无评论...
验证码 换一张
取 消