How to show full stack trace on eclipse?

前端 未结 7 1270
忘掉有多难
忘掉有多难 2020-12-01 20:20

I\'m using Eclipse to debug a Java application. Somewhere in the code I get an exception and the stack trace:

Caused by: java.io.EOFException: The connection         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 21:19

    the answers above are not accurate, every time the stack show the words "caused by" it means that the exception went through one or multiple methods until it was caught, and then thrown again. This could happen many many many times, the stack trace is not a loop, it is a single direction, so no, the stuff at the top does not relate to the stuff at the bottom, the most important part IS at the bottom, that is the root of the exception, so if you would have:

    Exception in class main: blah blah blah ...lines of code... caused by FileNotFoundException ...lines of code... caused by: MalformedURLException ...lines of code... caused by: NullPointerException

    then you would not want to focus so much on the FileNotFoundException, but you would want to focus more on the NullPointerException. Like say you had a properties file with a file name in it. If accidentally used mykey, to find the property "myKey", then the propertiesResource would return a null, that would then get thrown all the way through all the lines of code (hopefully) to your application where the last catch block is. . . wich, at this piont, it would be "wrapped" not as a nullException, but as a FileNotFoundException. . .

提交回复
热议问题