title: Exception handling at the top layer
body: <p>Of course exceptions should be handled at the appropriate level you think and appropriately. Suppose you don't know what to do with checked exception and you wrap it in appropriate custom unchecked exception just to propagate up to the top level (it is supposed that you don't handle that wrapped exception and other possible unchecked exceptions at some medium level up apart the level which original exception occurred at (because of you don't want or don't know how)). Go further, All unhandled exceptions (unchecked and checked, that were wrapped in unchecked) reached the top level (main method, controller of webapp, etc); of course I should something to do. All I want to do is to notify the developer by using log entry that something was wrong and communicate the user that his request can't be serviced correctly (using different messages in dependence of what message is appropriate for that exception). To do that, I use in catch block <code>RuntimeException</code> (if it catches not custom unchecked exception, I’ll send the user a message "Serious problem occurred" or something like that; probability that such not custom unchecked exception will be cached greater than zero, and you must communicate about it). Some articles (<a href="http://www.onjava.com/pub/a/onjava/2003/11/19/exceptions.html?page=1" rel="nofollow">first</a>, <a href="http://howtodoinjava.com/2013/04/04/java-exception-handling-best-practices/" rel="nofollow">second</a>) advise not to catch instances of subclasses by super type in catch block (or it is only related to checked exceptions?). If I used accurate types of exceptions in catch blocks I would miss some unchecked exceptions and application would crash (and of course there would be duplicate code snippets in those catch blocks performing logging and notifying the user). As an example, I can provide the snippet that is constructed in jsp translation phase and uses super type to catch instances of subclasses of that supertype  </p>
  
  <pre><code>// some code
  try {
      // body of translated JSP here...
  } catch (Exception e) {
      out.clear();
      pageContext.handlePageException(e);
  }
  // some code  
  </code></pre>
  
  <p>My question: <strong>is this concept is correct to use <code>RuntimeException</code> in catch block at the top level to report about all problems to developer and communicate the user about all occurred problems?</strong> Of course, exception handling in this case is reduced to just notifying developer and user that the problems occurred and there are no recovering strategies. Maybe it is hard to call that concept as exception handling. Please correct me and I appreciate any ideas about that concept.</p>