title: Why do Java people frequently consume exceptions silently?
body: <p>I never did any serious Java coding before, but I learned the syntax, libraries, and concepts based on my existing skills (Delphi &amp; C#).  One thing I hardly understand is that I've seen so much code that silently consume exceptions after <code>printStackTrace</code> like this:</p>
  
  <pre><code>    public void process() {
          try {
              System.out.println("test");
          } catch(Exception e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>There is similar code like this one in almost every Java article &amp; project I ran into. Based on my knowledge this is very bad. The exception should almost always be forwarded to the outer context like this:</p>
  
  <pre><code>    public void process() {
          try {
              System.out.println("test");
          } catch(Exception e) {
              e.printStackTrace();
              throw new AssertionError(e);
          }
      }
  </code></pre>
  
  <p>Most of the time the exception should end up being handled at the outermost loop which belongs to the underlying framework (Java Swing for example). Why does it look like the norm to code like this in the Java world? I'm puzzled.</p>
  
  <p>Based on my background, I'd prefer to remove printStackTrace <em>entirely</em>. I would simply rethrow as an unhandled aka <code>RuntimeException</code> (or, even better, <code>AssertionError</code>), then catch and log it at the most appropriate place: the framework outermost loop.</p>
  
  <pre><code>    public void process() {
          try {
              System.out.println("test");
          } catch(Exception e) {
              throw new AssertionError(e);
          }
      }
  </code></pre>