Author: ningjiang
Date: Thu Dec 15 07:10:05 2011
New Revision: 1214639

URL: http://svn.apache.org/viewvc?rev=1214639&view=rev
Log:
CAMEL-4781 Improving NoTypeConversionAvailableException message with cause

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java?rev=1214639&r1=1214638&r2=1214639&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java
 Thu Dec 15 07:10:05 2011
@@ -34,8 +34,9 @@ public class NoTypeConversionAvailableEx
     }
 
     public NoTypeConversionAvailableException(Object value, Class<?> type, 
Throwable cause) {
-        this(value, type);
-        initCause(cause);
+        super(createMessage(value, type, cause), cause);
+        this.value = value;
+        this.type = type;
     }
 
     /**
@@ -71,4 +72,13 @@ public class NoTypeConversionAvailableEx
         return "No type converter available to convert from type: " + (value 
!= null ? value.getClass().getCanonicalName() : null)
               + " to the required type: " + type.getCanonicalName() + " with 
value " + value;
     }
+    
+    /**
+     * Returns an error message for no type converter available with the cause.
+     */
+    public static String createMessage(Object value, Class<?> type, Throwable 
cause) {
+        return "Converting Exception when converting from type: "
+               + (value != null ? value.getClass().getCanonicalName() : null) 
+ " to the required type: "
+               + type.getCanonicalName() + " with value " + value + ", which 
is caused by " + cause;
+    }
 }


Reply via email to