/src/main/java/org/exoplatform/social/client/api/event/LifecycleException.java

http://github.com/exosocial/exo.social.client · Java · 139 lines · 38 code · 42 blank · 59 comment · 6 complexity · e1ddf4289f4272a08795646b5a39cc39 MD5 · raw file

  1. /*
  2. * Copyright (C) 2003-2011 eXo Platform SAS.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Affero General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. package org.exoplatform.social.client.api.event;
  18. /**
  19. * General purpose exception that is thrown to indicate a lifecycle related
  20. * problem. Such exceptions should generally be considered fatal to the
  21. * operation of the application containing this component.
  22. */
  23. public final class LifecycleException extends RuntimeException {
  24. //------------------------------------------------------------ Constructors
  25. /**
  26. * Construct a new LifecycleException with no other information.
  27. */
  28. public LifecycleException() {
  29. this(null, null);
  30. }
  31. /**
  32. * Construct a new LifecycleException for the specified message.
  33. *
  34. * @param message Message describing this exception
  35. */
  36. public LifecycleException(String message) {
  37. this(message, null);
  38. }
  39. /**
  40. * Construct a new LifecycleException for the specified throwable.
  41. *
  42. * @param cause Throwable that caused this exception
  43. */
  44. public LifecycleException(Throwable cause) {
  45. this(null, cause);
  46. }
  47. /**
  48. * Construct a new LifecycleException for the specified message
  49. * and throwable.
  50. *
  51. * @param message Message describing this exception
  52. * @param cause Throwable that caused this exception
  53. */
  54. public LifecycleException(String message, Throwable cause) {
  55. super();
  56. this.message = message;
  57. this.cause = cause;
  58. }
  59. //------------------------------------------------------ Instance Variables
  60. /**
  61. * The error message passed to our constructor (if any)
  62. */
  63. protected String message = null;
  64. /**
  65. * The underlying exception or error passed to our constructor (if any)
  66. */
  67. protected Throwable cause = null;
  68. //---------------------------------------------------------- Public Methods
  69. /**
  70. * Returns the message associated with this exception, if any.
  71. */
  72. public String getMessage() {
  73. return (message);
  74. }
  75. /**
  76. * Returns the throwable that caused this exception, if any.
  77. */
  78. public Throwable getCause() {
  79. return (cause);
  80. }
  81. /**
  82. * Returns a formatted string that describes this exception.
  83. */
  84. public String toString() {
  85. StringBuffer sb = new StringBuffer("LifecycleException: ");
  86. if (message != null) {
  87. sb.append(message);
  88. if (cause != null) {
  89. sb.append(": ");
  90. }
  91. }
  92. if (cause != null) {
  93. sb.append(cause.toString());
  94. }
  95. return (sb.toString());
  96. }
  97. }