Open
Description
There are currently 4 articles about exceptions on dev.java.
However, none of them seem to explain what exactly a stack trace is, how to read it and how to find out where the issue is.
I frequently see new Java users (e.g. students) being confused by (especially bigger) stack traces with no idea on how to debug them.
While this Stack Overflow post explains it quite well, I think this is a good fit and would be a helpful article (especially for referencing it to new Java developers).
I would like such an article to contain the following:
- What is a stack trace?
- When is a stack trace displayed on the console (or in other logs)?
- What is a
Caused By
section? - What is a
Suppressed
section? - What should people look at/focus on when reading (bigger) stack traces?
- Differentiating between own code and other code (in frameworks)
- Why is it often a bad idea to use
System.out.println("error");
instead ofe.printStackTrace();
(or re-throwing) in acatch
-block for exceptions that shouldn't happen?