You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2018/11/08 15:00:19 UTC
[camel] 05/08: Improve TypeConversionException message
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch sandbox/camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 958b12e1a8c45ef63c9ad1cdc270664c45552f81
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Nov 8 10:26:35 2018 +0100
Improve TypeConversionException message
---
.../src/main/java/org/apache/camel/TypeConversionException.java | 2 +-
.../test/java/org/apache/camel/builder/xml/XPathFeatureTest.java | 6 +++---
.../src/test/java/org/apache/camel/impl/DefaultComponentTest.java | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/camel-api/src/main/java/org/apache/camel/TypeConversionException.java b/camel-api/src/main/java/org/apache/camel/TypeConversionException.java
index 4632318..a6b7e01 100644
--- a/camel-api/src/main/java/org/apache/camel/TypeConversionException.java
+++ b/camel-api/src/main/java/org/apache/camel/TypeConversionException.java
@@ -62,7 +62,7 @@ public class TypeConversionException extends RuntimeCamelException {
*/
public static String createMessage(Object value, Class<?> type, Throwable cause) {
return "Error during type conversion from type: " + (value != null ? value.getClass().getCanonicalName() : null)
- + " to the required type: " + type.getCanonicalName() + " with value " + value + " due " + cause.getMessage();
+ + " to the required type: " + type.getCanonicalName() + " with value " + value + " due to " + cause.getClass().getName() + ": " + cause.getMessage();
}
}
diff --git a/camel-core/src/test/java/org/apache/camel/builder/xml/XPathFeatureTest.java b/camel-core/src/test/java/org/apache/camel/builder/xml/XPathFeatureTest.java
index 50ff16b..d78dbef 100644
--- a/camel-core/src/test/java/org/apache/camel/builder/xml/XPathFeatureTest.java
+++ b/camel-core/src/test/java/org/apache/camel/builder/xml/XPathFeatureTest.java
@@ -58,7 +58,7 @@ public class XPathFeatureTest extends ContextTestSupport {
xpath("/").stringResult().evaluate(createExchange(XML_DATA));
fail("Expect an Exception here");
} catch (TypeConversionException ex) {
- assertTrue("Get a wrong exception cause.", ex.getCause() instanceof FileNotFoundException);
+ assertTrue("Get a wrong exception cause: " + ex.getCause().getClass() + " instead of " + FileNotFoundException.class, ex.getCause() instanceof FileNotFoundException);
} finally {
System.clearProperty(DOM_BUILDER_FACTORY_FEATURE + ":"
+ "http://xml.org/sax/features/external-general-entities");
@@ -72,7 +72,7 @@ public class XPathFeatureTest extends ContextTestSupport {
xpath("/").documentType(Exchange.class).stringResult().evaluate(createExchange(XML_DATA));
fail("Expect an Exception here");
} catch (RuntimeCamelException ex) {
- assertTrue("Get a wrong exception cause.", ex.getCause() instanceof NoTypeConversionAvailableException);
+ assertTrue("Get a wrong exception cause: " + ex.getCause().getClass() + " instead of " + NoTypeConversionAvailableException.class, ex.getCause() instanceof NoTypeConversionAvailableException);
}
}
@@ -82,7 +82,7 @@ public class XPathFeatureTest extends ContextTestSupport {
xpath("/").stringResult().evaluate(createExchange(XML_DATA_INVALID));
fail("Expect an Exception here");
} catch (TypeConversionException ex) {
- assertTrue("Get a wrong exception cause.", ex.getCause() instanceof SAXParseException);
+ assertTrue("Get a wrong exception cause: " + ex.getCause().getClass() + " instead of " + SAXParseException.class, ex.getCause() instanceof SAXParseException);
}
}
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java
index 6a9b907..94b11dd 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java
@@ -121,7 +121,7 @@ public class DefaultComponentTest extends ContextTestSupport {
} catch (TypeConversionException ex) {
assertEquals("Error during type conversion from type: java.lang.String "
+ "to the required type: java.lang.Integer "
- + "with value abc due For input string: \"abc\"", ex.getMessage());
+ + "with value abc due to java.lang.NumberFormatException: For input string: \"abc\"", ex.getMessage());
}
}