Extracting meaningful information from stacktrace
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:
- 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.
- 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.
精彩评论