FileDocCategorySizeDatePackage
MessagingException.javaAPI DocJavaMail 1.4.35432Tue Nov 17 10:38:12 GMT 2009javax.mail

MessagingException

public class MessagingException extends Exception
The base class for all exceptions thrown by the Messaging classes
author
John Mani
author
Bill Shannon

Fields Summary
private Exception
next
The next exception in the chain.
private static final long
serialVersionUID
Constructors Summary
public MessagingException()
Constructs a MessagingException with no detail message.


                
      
	super();
	initCause(null);	// prevent anyone else from setting it
    
public MessagingException(String s)
Constructs a MessagingException with the specified detail message.

param
s the detail message

	super(s);
	initCause(null);	// prevent anyone else from setting it
    
public MessagingException(String s, Exception e)
Constructs a MessagingException with the specified Exception and detail message. The specified exception is chained to this exception.

param
s the detail message
param
e the embedded exception
see
#getNextException
see
#setNextException
see
#getCause

	super(s);
	next = e;
	initCause(null);	// prevent anyone else from setting it
    
Methods Summary
public synchronized java.lang.ThrowablegetCause()
Overrides the getCause method of Throwable to return the next exception in the chain of nested exceptions.

return
next Exception, null if none.

	return next;
    
public synchronized java.lang.ExceptiongetNextException()
Get the next exception chained to this one. If the next exception is a MessagingException, the chain may extend further.

return
next Exception, null if none.

	return next;
    
public synchronized booleansetNextException(java.lang.Exception ex)
Add an exception to the end of the chain. If the end is not a MessagingException, this exception cannot be added to the end.

param
ex the new end of the Exception chain
return
true if this Exception was added, false otherwise.

	Exception theEnd = this;
	while (theEnd instanceof MessagingException &&
	       ((MessagingException)theEnd).next != null) {
	    theEnd = ((MessagingException)theEnd).next;
	}
	// If the end is a MessagingException, we can add this 
	// exception to the chain.
	if (theEnd instanceof MessagingException) {
	    ((MessagingException)theEnd).next = ex;
	    return true;
	} else
	    return false;
    
private final java.lang.StringsuperToString()
Return the "toString" information for this exception, without any information on nested exceptions.

	return super.toString();
    
public synchronized java.lang.StringtoString()
Override toString method to provide information on nested exceptions.

	String s = super.toString();
	Exception n = next;
	if (n == null)
	    return s;
	StringBuffer sb = new StringBuffer(s == null ? "" : s);
	while (n != null) {
	    sb.append(";\n  nested exception is:\n\t");
	    if (n instanceof MessagingException) {
		MessagingException mex = (MessagingException)n;
		sb.append(mex.superToString());
		n = mex.next;
	    } else {
		sb.append(n.toString());
		n = null;
	    }
	}
	return sb.toString();