Skip to content

Method: SendFailedException(String, Exception)

1: /*
2: * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package jakarta.mail;
18:
19: /**
20: * This exception is thrown when the message cannot be sent.<p>
21: *
22: * The exception includes those addresses to which the message could not be
23: * sent as well as the valid addresses to which the message was sent and
24: * valid addresses to which the message was not sent.
25: *
26: * @see        jakarta.mail.Transport#send
27: * @see        jakarta.mail.Transport#sendMessage
28: * @see        jakarta.mail.event.TransportEvent
29: *
30: * @author John Mani
31: * @author Max Spivak
32: */
33:
34: public class SendFailedException extends MessagingException {
35: transient protected Address[] invalid;
36: transient protected Address[] validSent;
37: transient protected Address[] validUnsent;
38:
39: private static final long serialVersionUID = -6457531621682372913L;
40:
41: /**
42: * Constructs a SendFailedException with no detail message.
43: */
44: public SendFailedException() {
45:         super();
46: }
47:
48: /**
49: * Constructs a SendFailedException with the specified detail message.
50: * @param s                the detail message
51: */
52: public SendFailedException(String s) {
53:         super(s);
54: }
55:
56: /**
57: * Constructs a SendFailedException with the specified
58: * Exception and detail message. The specified exception is chained
59: * to this exception.
60: * @param s                the detail message
61: * @param e                the embedded exception
62: * @see        #getNextException
63: * @see        #setNextException
64: */
65: public SendFailedException(String s, Exception e) {
66:         super(s, e);
67: }
68:
69:
70: /**
71: * Constructs a SendFailedException with the specified string
72: * and the specified address objects.
73: *
74: * @param msg        the detail message
75: * @param ex the embedded exception
76: * @param validSent valid addresses to which message was sent
77: * @param validUnsent valid addresses to which message was not sent
78: * @param invalid         the invalid addresses
79: * @see        #getNextException
80: * @see        #setNextException
81: */
82: public SendFailedException(String msg, Exception ex, Address[] validSent,
83:                          Address[] validUnsent, Address[] invalid) {
84:         super(msg, ex);
85:         this.validSent = validSent;
86:         this.validUnsent = validUnsent;
87:         this.invalid = invalid;
88: }
89:
90: /**
91: * Return the addresses to which this message was sent succesfully.
92: * @return Addresses to which the message was sent successfully or null
93: */
94: public Address[] getValidSentAddresses() {
95:         return validSent;
96: }
97:
98: /**
99: * Return the addresses that are valid but to which this message
100: * was not sent.
101: * @return Addresses that are valid but to which the message was
102: * not sent successfully or null
103: */
104: public Address[] getValidUnsentAddresses() {
105:         return validUnsent;
106: }
107:
108: /**
109: * Return the addresses to which this message could not be sent.
110: *
111: * @return Addresses to which the message sending failed or null;
112: */
113: public Address[] getInvalidAddresses() {
114:         return invalid;
115: }
116: }