svn commit: r917372 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util: ObjectType.java test/ObjectTypeTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r917372 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util: ObjectType.java test/ObjectTypeTests.java

doogie-3
Author: doogie
Date: Mon Mar  1 03:19:08 2010
New Revision: 917372

URL: http://svn.apache.org/viewvc?rev=917372&view=rev
Log:
BUG FIX: Throw exceptions instead of logging errors.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java?rev=917372&r1=917371&r2=917372&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java Mon Mar  1 03:19:08 2010
@@ -488,8 +488,7 @@
         try {
             targetClass = loadClass(type);
         } catch (ClassNotFoundException e) {
-            Debug.logError(e, module);
-            return obj;
+            throw new GeneralException("Conversion from " + sourceClass.getName() + " to " + type + " not currently supported", e);
         }
         if (sourceClass.equals(targetClass)) {
             return obj;
@@ -513,13 +512,13 @@
                 try {
                     return localizedConverter.convert(obj, locale, timeZone, format);
                 } catch (ConversionException e) {
-                    Debug.logError(e, module);
+                    throw new GeneralException(e.getMessage(), e);
                 }
             }
             try {
                 return converter.convert(obj);
             } catch (ConversionException e) {
-                Debug.logError(e, module);
+                throw new GeneralException(e.getMessage(), e);
             }
         }
         if (obj instanceof Node) {

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java?rev=917372&r1=917371&r2=917372&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Mon Mar  1 03:19:08 2010
@@ -208,15 +208,15 @@
         // TZ can never be null, will default to GMT if it can't be parsed(from the javadocs of java.util.TimeZone)
         simpleTypeConvertTestSingleMulti("String->TimeZone", "Pacific/Wake", new String[] {"TimeZone", "java.util.TimeZone"}, localeData.goodTimeZone);
         simpleTypeConvertTestSingleMulti("String->BigDecimal", "78,125E-2", new String[] {"BigDecimal", "java.math.BigDecimal"}, null, localeData, dcml);
-        //BUG simpleTypeConvertTestError("String->error-BigDecimal", "o", new String[] {"BigDecimal", "java.math.BigDecimal"});
+        simpleTypeConvertTestError("String->error-BigDecimal", "o", new String[] {"BigDecimal", "java.math.BigDecimal"});
         simpleTypeConvertTestSingleMulti("String->Double", "78,125E-2", new String[] {"Double", "java.lang.Double"}, null, localeData, dbl);
-        //BUG simpleTypeConvertTestError("String->error-Double", "o", new String[] {"Double", "java.lang.Double"});
+        simpleTypeConvertTestError("String->error-Double", "o", new String[] {"Double", "java.lang.Double"});
         simpleTypeConvertTestSingleMulti("String->Float", "78,125E-2", new String[] {"Float", "java.lang.Float"}, null, localeData, flt);
-        //BUG simpleTypeConvertTestError("String->error-Float", "o", new String[] {"Float", "java.lang.Float"});
+        simpleTypeConvertTestError("String->error-Float", "o", new String[] {"Float", "java.lang.Float"});
         simpleTypeConvertTestSingleMulti("String->Long", "78,125E-2", new String[] {"Long", "java.lang.Long"}, null, localeData, lng);
-        //BUG simpleTypeConvertTestError("String->error-Long", "o", new String[] {"Long", "java.lang.Long"});
+        simpleTypeConvertTestError("String->error-Long", "o", new String[] {"Long", "java.lang.Long"});
         simpleTypeConvertTestSingleMulti("String->Integer", "78,125E-2", new String[] {"Integer", "java.lang.Integer"}, null, localeData, intg);
-        //BUG simpleTypeConvertTestError("String->error-Integer", "o", new String[] {"Integer", "java.lang.Integer"});
+        simpleTypeConvertTestError("String->error-Integer", "o", new String[] {"Integer", "java.lang.Integer"});
 
         simpleTypeConvertTestSingleMulti("String->java.sql.Date", "1969-12-31", new String[] {"Date", "java.sql.Date"}, null, localeData, sqlDt);
         simpleTypeConvertTestSingleMulti("String->java.sql.Date", "1969-12-31", new String[] {"Date", "java.sql.Date"}, "", localeData, sqlDt);
@@ -242,7 +242,7 @@
         simpleTypeConvertTestError("String->Map(error-2)", "one=1, two=2, three=3}", new String[] {"Map", "java.util.Map"});
         simpleTypeConvertTestSingleMulti("String->TimeDuration(number)", "3,661,001", new String[] {"TimeDuration", "org.ofbiz.base.util.TimeDuration"}, null, localeData, duration);
         simpleTypeConvertTestMultiMulti("String->TimeDuration(string)", new String[] {"1:1:1:1"}, new String[] {"TimeDuration", "org.ofbiz.base.util.TimeDuration"}, duration);
-        //BUG simpleTypeConvertTestError("String->error-TimeDuration", "o", new String[] {"TimeDuration", "org.ofbiz.base.util.TimeDuration"});
+        simpleTypeConvertTestError("String->error-TimeDuration", "o", new String[] {"TimeDuration", "org.ofbiz.base.util.TimeDuration"});
     }
 
     public void testDouble() throws GeneralException {