camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r638778 - in /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel: InvalidPayloadException.java util/ExchangeHelper.java
Date Wed, 19 Mar 2008 10:34:21 GMT
Author: jstrachan
Date: Wed Mar 19 03:34:13 2008
New Revision: 638778

URL: http://svn.apache.org/viewvc?rev=638778&view=rev
Log:
improved error messages

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidPayloadException.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidPayloadException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidPayloadException.java?rev=638778&r1=638777&r2=638778&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidPayloadException.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/InvalidPayloadException.java
Wed Mar 19 03:34:13 2008
@@ -23,8 +23,12 @@
     private final Class<?> type;
 
     public InvalidPayloadException(Exchange exchange, Class<?> type) {
+        this(exchange, type, exchange.getIn());
+    }
+
+    public InvalidPayloadException(Exchange exchange, Class<?> type, Message message)
{
         super("No in body available of type: " + type.getName()
-              + NoSuchPropertyException.valueDescription(exchange.getIn().getBody()), exchange);
+              + NoSuchPropertyException.valueDescription(message.getBody()) + " on: " + message,
exchange);
         this.type = type;
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java?rev=638778&r1=638777&r2=638778&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
Wed Mar 19 03:34:13 2008
@@ -125,9 +125,10 @@
      * an exception if it is not present
      */
     public static Object getMandatoryOutBody(Exchange exchange) throws InvalidPayloadException
{
-        Object answer = exchange.getOut().getBody();
+        Message out = exchange.getOut();
+        Object answer = out.getBody();
         if (answer == null) {
-            throw new InvalidPayloadException(exchange, Object.class);
+            throw new InvalidPayloadException(exchange, Object.class, out);
         }
         return answer;
     }
@@ -137,9 +138,10 @@
      * an exception if it is not present
      */
     public static <T> T getMandatoryOutBody(Exchange exchange, Class<T> type)
throws InvalidPayloadException {
-        T answer = exchange.getOut().getBody(type);
+        Message out = exchange.getOut();
+        T answer = out.getBody(type);
         if (answer == null) {
-            throw new InvalidPayloadException(exchange, type);
+            throw new InvalidPayloadException(exchange, type, out);
         }
         return answer;
     }



Mime
View raw message