1 42 43 44 package org.jahia.exceptions; 45 46 import java.io.PrintStream ; 47 import java.io.PrintWriter ; 48 49 public class JahiaException extends Exception 50 { 51 private static org.apache.log4j.Logger logger = 52 org.apache.log4j.Logger.getLogger(JahiaException.class); 53 54 public static final int WARNING_SEVERITY = 1; 55 public static final int ERROR_SEVERITY = 2; 56 public static final int CRITICAL_SEVERITY = 3; 57 public static final int KISSYOURASSGOODBYE_SEVERITY = 4; 58 59 public static final int INITIALIZATION_ERROR = 0; 60 public static final int DATABASE_ERROR = 1; 61 public static final int FILE_ERROR = 2; 62 public static final int DATA_ERROR = 3; 63 public static final int TEMPLATE_ERROR = 4; 64 public static final int PERSISTENCE_ERROR = 5; 65 66 67 68 public static final int USER_ERROR = 5; 69 70 71 public static final int PAGE_ERROR = 6; 72 73 public static final int WINDOW_ERROR = 7; 74 public static final int PARAMETER_ERROR = 8; 75 public static final int APPLICATION_ERROR = 9; 76 public static final int NEWSFEED_ERROR = 10; 77 public static final int CONFIG_ERROR = 11; 78 public static final int SERVICE_ERROR = 12; 79 public static final int REGISTRY_ERROR = 13; 80 public static final int SERVLET_ERROR = 14; 81 public static final int LISTENER_ERROR = 15; 82 83 84 public static final int SECURITY_ERROR = 16; 85 86 87 public static final int ACL_ERROR = 17; 88 89 public static final int CACHE_ERROR = 18; 90 public static final int OBJECT_ERROR = 19; 91 public static final int ENGINE_ERROR = 20; 92 93 94 public static final int LOCK_ERROR = 21; 95 96 97 public static final int SESSION_ERROR = 22; 98 99 100 protected static final int ACCOUNTS_ERROR = 23; 101 102 103 protected static final int LICENSE_ERROR = 24; 104 105 106 public static final int JEF_ERROR = 25; 107 108 109 public static final int JAVASECURITY_ERROR = 26; 110 111 112 public static final int ENGINE_VALIDATION_ERROR = 27; 113 114 115 public static final int UNAVAILABLE_ERROR = 28; 116 117 118 public static final int ENTRY_NOT_FOUND = 30; 119 120 121 public static final int SITE_NOT_FOUND = 40; 122 123 124 protected String mUserErrorMsg; 125 protected String mJahiaErrorMsg; 126 protected int mErrorCode; 127 protected int mErrorSeverity; 128 protected Throwable mRootCauseException; 129 130 131 132 138 public JahiaException (String userErrorMsg, 139 String jahiaErrorMsg, 140 int errorCode, 141 int errorSeverity) 142 { 143 super (userErrorMsg + ", " + jahiaErrorMsg); 144 145 mUserErrorMsg = userErrorMsg; 146 mJahiaErrorMsg = jahiaErrorMsg; 147 mErrorCode = errorCode; 148 mErrorSeverity = errorSeverity; 149 150 } 152 158 public JahiaException (String userErrorMsg, 159 String jahiaErrorMsg, 160 int errorCode, 161 int errorSeverity, 162 Throwable t) 163 { 164 super (userErrorMsg + ", " + jahiaErrorMsg + ", root cause:" + ((t == null) ? "null" : t.getMessage())); 165 166 mUserErrorMsg = userErrorMsg; 167 mJahiaErrorMsg = jahiaErrorMsg; 168 mErrorCode = errorCode; 169 mErrorSeverity = errorSeverity; 170 mRootCauseException = t; 171 172 } 173 174 175 181 public int getSeverity() 182 { 183 return mErrorSeverity; 184 } 186 187 194 public final String getUserErrorMsg () 195 { 196 return mUserErrorMsg; 197 } 198 199 200 207 public final String getJahiaErrorMsg () 208 { 209 return mJahiaErrorMsg; 210 } 211 212 213 220 public final int getErrorCode () 221 { 222 return mErrorCode; 223 } 224 225 232 public final Throwable getRootCause() { 233 return mRootCauseException; 234 } 235 236 239 public String toString() { 240 logger.debug("called."); 241 StringBuffer result = new StringBuffer (); 242 result.append(super.toString()); 243 if (getRootCause() != null) { 244 result.append(" root cause="); 245 result.append(getRootCause().toString()); 246 } 247 return result.toString(); 248 } 249 250 public void printStackTrace(PrintWriter s) { 251 logger.debug("(PrintWriter s) called."); 252 super.printStackTrace(s); 253 258 } 259 260 public void printStackTrace(PrintStream s) { 261 logger.debug("(PrintStream s) called."); 262 super.printStackTrace(s); 263 268 } 269 270 public void printStackTrace() { 271 logger.debug("() called."); 272 super.printStackTrace(); 273 278 } 279 280 } 282 283 | Popular Tags |