Author: doogie
Date: Fri Sep 5 21:10:17 2008
New Revision: 692610
URL:
http://svn.apache.org/viewvc?rev=692610&view=revLog:
A couple helper methods, so that calling code doesn't have to have so
many catch blocks.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GeneralException.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GeneralException.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GeneralException.java?rev=692610&r1=692609&r2=692610&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GeneralException.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GeneralException.java Fri Sep 5 21:10:17 2008
@@ -28,6 +28,17 @@
*/
public class GeneralException extends Exception {
+ public static <T> T checkException(Throwable t) throws GeneralException {
+ return GeneralException.<T>checkException(t.getMessage(), t);
+ }
+
+ public static <T> T checkException(String message, Throwable t) throws GeneralException {
+ if (t instanceof Error) throw (Error) t;
+ if (t instanceof RuntimeException) throw (RuntimeException) t;
+ if (t instanceof GeneralException) throw (GeneralException) t;
+ throw (GeneralException) new GeneralException(message).initCause(t);
+ }
+
Throwable nested = null;
List<String> messages = null;