1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.mail;
  6. /**
  7. * This exception is thrown when the message cannot be sent.<p>
  8. *
  9. * The exception includes those addresses to which the message could not be
  10. * sent as well as the valid addresses to which the message was sent and
  11. * valid addresses to which the message was not sent.
  12. *
  13. * @see javax.mail.Transport#send
  14. * @see javax.mail.Transport#sendMessage
  15. * @see javax.mail.event.TransportEvent
  16. *
  17. * @author John Mani
  18. * @author Max Spivak
  19. */
  20. public class SendFailedException extends MessagingException {
  21. transient protected Address[] invalid;
  22. transient protected Address[] validSent;
  23. transient protected Address[] validUnsent;
  24. /**
  25. * Constructs a SendFailedException with no detail message.
  26. */
  27. public SendFailedException() {
  28. super();
  29. }
  30. /**
  31. * Constructs a SendFailedException with the specified detail message.
  32. * @param s the detail message
  33. */
  34. public SendFailedException(String s) {
  35. super(s);
  36. }
  37. /**
  38. * Constructs a SendFailedException with the specified
  39. * Exception and detail message. The specified exception is chained
  40. * to this exception.
  41. * @param s the detail message
  42. * @param e the embedded exception
  43. * @see #getNextException
  44. * @see #setNextException
  45. */
  46. public SendFailedException(String s, Exception e) {
  47. super(s, e);
  48. }
  49. /**
  50. * Constructs a SendFailedException with the specified string
  51. * and the specified address objects.
  52. *
  53. * @param msg the detail message
  54. * @param ex the embedded exception
  55. * @param validSent valid addresses to which message was sent
  56. * @param validUnsent valid addresses to which message was not sent
  57. * @param invalid the invalid addresses
  58. * @see #getNextException
  59. * @see #setNextException
  60. */
  61. public SendFailedException(String msg, Exception ex, Address[] validSent,
  62. Address[] validUnsent, Address[] invalid) {
  63. super(msg, ex);
  64. this.validSent = validSent;
  65. this.validUnsent = validUnsent;
  66. this.invalid = invalid;
  67. }
  68. /**
  69. * Return the addresses to which this message was sent succesfully.
  70. * @return Addresses to which the message was sent successfully or null
  71. */
  72. public Address[] getValidSentAddresses() {
  73. return validSent;
  74. }
  75. /**
  76. * Return the addresses that are valid but to which this message
  77. * was not sent.
  78. * @return Addresses that are valid but to which the message was
  79. * not sent successfully or null
  80. */
  81. public Address[] getValidUnsentAddresses() {
  82. return validUnsent;
  83. }
  84. /**
  85. * Return the addresses to which this message could not be sent.
  86. *
  87. * @return Addresses to which the message sending failed or null;
  88. */
  89. public Address[] getInvalidAddresses() {
  90. return invalid;
  91. }
  92. }