/src/main/java/org/exoplatform/social/client/api/event/LifecycleException.java
Java | 139 lines | 38 code | 42 blank | 59 comment | 6 complexity | e1ddf4289f4272a08795646b5a39cc39 MD5 | raw file
Possible License(s): AGPL-3.0
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 */ 17package org.exoplatform.social.client.api.event; 18 19 20/** 21 * General purpose exception that is thrown to indicate a lifecycle related 22 * problem. Such exceptions should generally be considered fatal to the 23 * operation of the application containing this component. 24 */ 25public final class LifecycleException extends RuntimeException { 26 27 28 //------------------------------------------------------------ Constructors 29 30 31 /** 32 * Construct a new LifecycleException with no other information. 33 */ 34 public LifecycleException() { 35 36 this(null, null); 37 38 } 39 40 41 /** 42 * Construct a new LifecycleException for the specified message. 43 * 44 * @param message Message describing this exception 45 */ 46 public LifecycleException(String message) { 47 48 this(message, null); 49 50 } 51 52 53 /** 54 * Construct a new LifecycleException for the specified throwable. 55 * 56 * @param cause Throwable that caused this exception 57 */ 58 public LifecycleException(Throwable cause) { 59 60 this(null, cause); 61 62 } 63 64 65 /** 66 * Construct a new LifecycleException for the specified message 67 * and throwable. 68 * 69 * @param message Message describing this exception 70 * @param cause Throwable that caused this exception 71 */ 72 public LifecycleException(String message, Throwable cause) { 73 74 super(); 75 this.message = message; 76 this.cause = cause; 77 78 } 79 80 81 //------------------------------------------------------ Instance Variables 82 83 84 /** 85 * The error message passed to our constructor (if any) 86 */ 87 protected String message = null; 88 89 90 /** 91 * The underlying exception or error passed to our constructor (if any) 92 */ 93 protected Throwable cause = null; 94 95 96 //---------------------------------------------------------- Public Methods 97 98 99 /** 100 * Returns the message associated with this exception, if any. 101 */ 102 public String getMessage() { 103 104 return (message); 105 106 } 107 108 109 /** 110 * Returns the throwable that caused this exception, if any. 111 */ 112 public Throwable getCause() { 113 114 return (cause); 115 116 } 117 118 119 /** 120 * Returns a formatted string that describes this exception. 121 */ 122 public String toString() { 123 124 StringBuffer sb = new StringBuffer("LifecycleException: "); 125 if (message != null) { 126 sb.append(message); 127 if (cause != null) { 128 sb.append(": "); 129 } 130 } 131 if (cause != null) { 132 sb.append(cause.toString()); 133 } 134 return (sb.toString()); 135 136 } 137 138 139}