--- MessagingException.java~ 2007-04-24 19:45:00.146875200 -0700 +++ MessagingException.java 2007-04-24 19:44:18.136467200 -0700 @@ -74,7 +74,6 @@ * @param e the embedded exception * @see #getNextException * @see #setNextException - * @see #getCause */ public MessagingException(String s, Exception e) { super(s); @@ -94,16 +93,6 @@ } /** - * Overrides the getCause method of Throwable - * to return the next exception in the chain of nested exceptions. - * - * @return next Exception, null if none. - */ - public synchronized Throwable getCause() { - return next; - } - - /** * Add an exception to the end of the chain. If the end * is not a MessagingException, this * exception cannot be added to the end. @@ -132,14 +121,12 @@ * nested exceptions. */ public synchronized String toString() { - String s = super.toString(); + StringBuffer sb = new StringBuffer(); + sb = appendException(sb, this); 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"); - sb.append(n.toString()); + sb = appendException(sb, n); if (n instanceof MessagingException) { MessagingException mex = (MessagingException)n; n = mex.next; @@ -149,4 +136,13 @@ } return sb.toString(); } + + private static StringBuffer appendException(StringBuffer sb, Exception e) { + // pretty much a copy of Throwable.toString() + sb.append(e.getClass().getName()); + String message = e.getLocalizedMessage(); + if (message != null) + sb.append(": ").append(message); + return sb; + } }