1 21 22 27 28 package javax.mail; 29 30 import java.lang.*; 31 32 38 39 public class MessagingException extends Exception { 40 41 46 private Exception next; 47 48 private static final long serialVersionUID = -7569192289819959253L; 49 50 53 public MessagingException() { 54 super(); 55 initCause(null); } 57 58 63 public MessagingException(String s) { 64 super(s); 65 initCause(null); } 67 68 79 public MessagingException(String s, Exception e) { 80 super(s); 81 next = e; 82 initCause(null); } 84 85 92 public synchronized Exception getNextException() { 93 return next; 94 } 95 96 102 public synchronized Throwable getCause() { 103 return next; 104 } 105 106 115 public synchronized boolean setNextException(Exception ex) { 116 Exception theEnd = this; 117 while (theEnd instanceof MessagingException && 118 ((MessagingException )theEnd).next != null) { 119 theEnd = ((MessagingException )theEnd).next; 120 } 121 if (theEnd instanceof MessagingException ) { 124 ((MessagingException )theEnd).next = ex; 125 return true; 126 } else 127 return false; 128 } 129 130 134 public synchronized String toString() { 135 String s = super.toString(); 136 Exception n = next; 137 if (n == null) 138 return s; 139 StringBuffer sb = new StringBuffer (s == null ? "" : s); 140 while (n != null) { 141 sb.append(";\n nested exception is:\n\t"); 142 sb.append(n.toString()); 143 if (n instanceof MessagingException ) { 144 MessagingException mex = (MessagingException )n; 145 n = mex.next; 146 } else { 147 n = null; 148 } 149 } 150 return sb.toString(); 151 } 152 } 153 | Popular Tags |