1 56 package org.objectstyle.cayenne; 57 58 import org.objectstyle.cayenne.util.LocalizedStringsHandler; 59 60 70 public class CayenneException extends Exception { 71 private static String exceptionLabel; 72 73 static { 74 String version = LocalizedStringsHandler.getString("cayenne.version"); 75 String date = LocalizedStringsHandler.getString("cayenne.build.date"); 76 77 if (version != null || date != null) { 78 exceptionLabel = "[v." + version + " " + date + "] "; 79 } 80 else { 81 exceptionLabel = ""; 82 } 83 } 84 85 public static String getExceptionLabel() { 86 return exceptionLabel; 87 } 88 89 private Throwable _cause; 90 91 94 public CayenneException() { 95 } 96 97 101 public CayenneException(String msg) { 102 super(msg); 103 } 104 105 109 public CayenneException(Throwable th) { 110 this(th == null ? (String ) null : th.toString(), th); 111 } 112 113 public CayenneException(String msg, Throwable th) { 114 super(msg); 115 this._cause = th; 116 } 117 118 121 public Throwable getCause() { 122 return _cause; 123 } 124 125 130 public String getUnlabeledMessage() { 131 return super.getMessage(); 132 } 133 134 public String getMessage() { 135 String message = super.getMessage(); 136 return (message != null) 137 ? getExceptionLabel() + message 138 : getExceptionLabel() + "(no message)"; 139 } 140 } 141 | Popular Tags |