Coverage Report - org.apache.commons.mail.EmailException
 
Classes in this File Line Coverage Branch Coverage Complexity
EmailException
30%
6/20
N/A
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.apache.commons.mail;
 19  
 
 20  
 import java.io.PrintStream;
 21  
 import java.io.PrintWriter;
 22  
 
 23  
 /**
 24  
  * Exception thrown when a checked error occurs in commons-email.
 25  
  * <p>
 26  
  * Adapted from FunctorException in Commons Collections.
 27  
  * <p>
 28  
  * Emulation support for nested exceptions has been removed in {@code Email 1.3},
 29  
  * supported by JDK &ge; 1.4.
 30  
  *
 31  
  * @author jakarta-commons
 32  
  * @since 1.0
 33  
  * @version $Id: EmailException.java 1420381 2012-12-11 20:18:05Z tn $
 34  
  */
 35  
 public class EmailException
 36  
         extends Exception
 37  
 {
 38  
     /** Serializable version identifier. */
 39  
     private static final long serialVersionUID = 5550674499282474616L;
 40  
 
 41  
     /**
 42  
      * Constructs a new <code>EmailException</code> with no
 43  
      * detail message.
 44  
      */
 45  
     public EmailException()
 46  
     {
 47  0
         super();
 48  0
     }
 49  
 
 50  
     /**
 51  
      * Constructs a new <code>EmailException</code> with specified
 52  
      * detail message.
 53  
      *
 54  
      * @param msg  the error message.
 55  
      */
 56  
     public EmailException(String msg)
 57  
     {
 58  36
         super(msg);
 59  36
     }
 60  
 
 61  
     /**
 62  
      * Constructs a new <code>EmailException</code> with specified
 63  
      * nested <code>Throwable</code> root cause.
 64  
      *
 65  
      * @param rootCause  the exception or error that caused this exception
 66  
      *                   to be thrown.
 67  
      */
 68  
     public EmailException(Throwable rootCause)
 69  
     {
 70  116
         super(rootCause);
 71  116
     }
 72  
 
 73  
     /**
 74  
      * Constructs a new <code>EmailException</code> with specified
 75  
      * detail message and nested <code>Throwable</code> root cause.
 76  
      *
 77  
      * @param msg  the error message.
 78  
      * @param rootCause  the exception or error that caused this exception
 79  
      *                   to be thrown.
 80  
      */
 81  
     public EmailException(String msg, Throwable rootCause)
 82  
     {
 83  8
         super(msg, rootCause);
 84  8
     }
 85  
 
 86  
     /**
 87  
      * Prints the stack trace of this exception to the standard error stream.
 88  
      */
 89  
     @Override
 90  
     public void printStackTrace()
 91  
     {
 92  0
         printStackTrace(System.err);
 93  0
     }
 94  
 
 95  
     /**
 96  
      * Prints the stack trace of this exception to the specified stream.
 97  
      *
 98  
      * @param out  the <code>PrintStream</code> to use for output
 99  
      */
 100  
     @Override
 101  
     public void printStackTrace(PrintStream out)
 102  
     {
 103  0
         synchronized (out)
 104  
         {
 105  0
             PrintWriter pw = new PrintWriter(out, false);
 106  0
             printStackTrace(pw);
 107  
 
 108  
             // Flush the PrintWriter before it's GC'ed.
 109  0
             pw.flush();
 110  0
         }
 111  0
     }
 112  
 
 113  
     /**
 114  
      * Prints the stack trace of this exception to the specified writer.
 115  
      *
 116  
      * @param out  the <code>PrintWriter</code> to use for output
 117  
      */
 118  
     @Override
 119  
     public void printStackTrace(PrintWriter out)
 120  
     {
 121  0
         synchronized (out)
 122  
         {
 123  0
             super.printStackTrace(out);
 124  0
         }
 125  0
     }
 126  
 }