I'm thinking about the following proposed method in UtilMisc.
Included in the diff is the new method, and one example usage.  If it
is used more often, the size of the code will become smaller.

However, I'm not entirely certain if it would be useful, and it's such
a very small helper method, I'm wondering whether the utility is
actually worth it.  What do you guys think?

=== framework/base/src/org/ofbiz/base/util/UtilMisc.java
==================================================================
--- framework/base/src/org/ofbiz/base/util/UtilMisc.java        (revision 8717)
+++ framework/base/src/org/ofbiz/base/util/UtilMisc.java        (local)
@@ -46,6 +46,11 @@
 
     public static final BigDecimal ZERO_BD = BigDecimal.ZERO;
 
+    public static final <T extends Throwable> T initCause(T throwable, 
Throwable cause) {
+        throwable.initCause(cause);
+        return throwable;
+    }
+
     /**
      * Get an iterator from a collection, returning null if collection is null
      * @param col The collection to be turned in to an iterator
=== framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
==================================================================
--- framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java       
(revision 8717)
+++ framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java       
(local)
@@ -97,7 +97,7 @@
             resources = loader.getResources("freemarkerTransforms.properties");
         } catch (IOException e) {
             Debug.logError(e, "Could not load list of 
freemarkerTransforms.properties", module);
-            throw (InternalError) new 
InternalError(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new InternalError(e.getMessage()), e);
         }
         while (resources.hasMoreElements()) {
             URL propertyURL = resources.nextElement();

Reply via email to