title: Custom Exception that wraps Multiple Exceptions : Encouraged or Not?
body: <p>I am coding a Java Library that will be used to access a DB.
  I am throwing the exceptions to the end-programmer who uses the JAR library to handle it the way he/she wants.</p>
  
  <p>I wrote a custom Exception (provided below) to wrap connection specific exceptions together so the end-programmer will not have to catch all these exceptions in his code. (to make it easy for him)</p>
  
  <p>is this a good practice when it comes to coding Java libraries? 
  By using this the user will only have to catch NConnectionException in his code.</p>
  
  <pre><code>public class NConnectionException extends Exception {
  private static final Logger logger = LoggerFactory.getLogger(NConnectionException.class);
  public NConnectionException(Exception e) {
  
      if (e instanceof NullPointerException) {
          logger.error("ERROR IN READING DF");
          e.printStackTrace();
      }
  
      else if (e instanceof FileNotFoundException) {
          logger.error("FILE NOT FOUND");
          e.printStackTrace();
  
      } else if (e instanceof ParserConfigurationException)
      {
          logger.error("PARSE CONF ERR");
          e.printStackTrace();
  
      }
      else if (e instanceof org.xml.sax.SAXException)
      {
          logger.error("SAX ERR");
          e.printStackTrace();
  
      }
      else if (e instanceof IOException)
      {
          logger.error("IO ERR");
          e.printStackTrace();
  
      }
  
  }
  </code></pre>
  
  <p>}</p>