1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
67 * Constructs a MessagingException with the specified
68 * Exception and detail message. The specified exception is chained
69 * to this exception.
70 * @param s the detail message
71 * @param e the embedded exception
72 * @see #getNextException
73 * @see #setNextException
74 */
75 public MessagingException(String s, Exception e) {
76 super(s);
77 next = e;
78 }
79
80 /**
81 * Get the next exception chained to this one. If the
82 * next exception is a MessagingException, the chain
83 * may extend further.
84 *
85 * @return next Exception, null if none.
86 */
87 public Exception getNextException() {
88 return next;
89 }
90
91 /**
92 * Add an exception to the end of the chain. If the end
93 * is <strong>not</strong> a MessagingException, this
94 * exception cannot be added to the end.
95 *
96 * @param ex the new end of the Exception chain
97 * @return <code>true</code> if the this Exception
98 * was added, <code>false</code> otherwise.
99 */
100 public synchronized boolean setNextException(Exception ex) {
101 Exception theEnd = this;
102 while (theEnd instanceof MessagingException &&
103 ((MessagingException)theEnd).next != null) {
104 theEnd = ((MessagingException)theEnd).next;
105 }
106 // If the end is a MessagingException, we can add this
107 // exception to the chain.
|
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
67 * Constructs a MessagingException with the specified
68 * Exception and detail message. The specified exception is chained
69 * to this exception.
70 * @param s the detail message
71 * @param e the embedded exception
72 * @see #getNextException
73 * @see #setNextException
74 */
75 public MessagingException(String s, Exception e) {
76 super(s);
77 next = e;
78 }
79
80 /**
81 * Get the next exception chained to this one. If the
82 * next exception is a MessagingException, the chain
83 * may extend further.
84 *
85 * @return next Exception, null if none.
86 */
87 public synchronized Exception getNextException() {
88 return next;
89 }
90
91 /**
92 * Add an exception to the end of the chain. If the end
93 * is <strong>not</strong> a MessagingException, this
94 * exception cannot be added to the end.
95 *
96 * @param ex the new end of the Exception chain
97 * @return <code>true</code> if the this Exception
98 * was added, <code>false</code> otherwise.
99 */
100 public synchronized boolean setNextException(Exception ex) {
101 Exception theEnd = this;
102 while (theEnd instanceof MessagingException &&
103 ((MessagingException)theEnd).next != null) {
104 theEnd = ((MessagingException)theEnd).next;
105 }
106 // If the end is a MessagingException, we can add this
107 // exception to the chain.
|