1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package javax.mail;
21
22
23
24
25 public class MessagingException extends Exception {
26
27 private Exception next;
28
29 public MessagingException() {
30 super();
31 }
32
33 public MessagingException(String message) {
34 super(message);
35 }
36
37 public MessagingException(String message, Exception cause) {
38 super(message, cause);
39 next = cause;
40 }
41
42 public Exception getNextException() {
43 return next;
44 }
45
46 public synchronized boolean setNextException(Exception cause) {
47 if (next == null) {
48 initCause(cause);
49 next = cause;
50 return true;
51 } else if (next instanceof MessagingException) {
52 return ((MessagingException) next).setNextException(cause);
53 } else {
54 return false;
55 }
56 }
57
58 public String getMessage() {
59 Exception next = getNextException();
60 if (next == null) {
61 return super.getMessage();
62 } else {
63 return super.getMessage()
64 + " ("
65 + next.getClass().getName()
66 + ": "
67 + next.getMessage()
68 + ")";
69 }
70 }
71 }