You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ds...@apache.org on 2007/07/26 14:10:13 UTC

svn commit: r559788 - /webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java

Author: dsosnoski
Date: Thu Jul 26 05:10:13 2007
New Revision: 559788

URL: http://svn.apache.org/viewvc?view=rev&rev=559788
Log:
Improve exception handling to pass root cause message

Modified:
    webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java

Modified: webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java?view=diff&rev=559788&r1=559787&r2=559788
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java (original)
+++ webservices/axis2/trunk/java/modules/jibx/src/org/apache/axis2/jibx/JiBXDataSource.java Thu Jul 26 05:10:13 2007
@@ -164,7 +164,12 @@
         try {
             
             if (marshallerIndex < 0) {
-                ((IMarshallable)dataObject).marshal(ctx);
+                if (dataObject instanceof IMarshallable) {
+                    ((IMarshallable)dataObject).marshal(ctx);
+                } else {
+                    throw new IllegalStateException("Object of class " + dataObject.getClass().getName() +
+                        " needs a JiBX <mapping> to be marshalled");
+                }
             } else {
                 IXMLWriter wrtr = ctx.getXmlWriter();
                 String name = elementName;
@@ -195,7 +200,7 @@
             ctx.getXmlWriter().flush();
 
         } catch (IOException e) {
-            throw new JiBXException("Error marshalling XML representation", e);
+            throw new JiBXException("Error marshalling XML representation: " + e.getMessage(), e);
         }
     }
 
@@ -211,7 +216,7 @@
             marshal(true, ctx);
             
         } catch (JiBXException e) {
-            throw new XMLStreamException("Error in JiBX marshalling", e);
+            throw new XMLStreamException("Error in JiBX marshalling: " + e.getMessage(), e);
         }
     }
 
@@ -227,7 +232,7 @@
             marshal(true, ctx);
             
         } catch (JiBXException e) {
-            throw new XMLStreamException("Error in JiBX marshalling", e);
+            throw new XMLStreamException("Error in JiBX marshalling: " + e.getMessage(), e);
         }
     }
 
@@ -262,7 +267,7 @@
             marshal(full, ctx);
             
         } catch (JiBXException e) {
-            throw new XMLStreamException("Error in JiBX marshalling", e);
+            throw new XMLStreamException("Error in JiBX marshalling: " + e.getMessage(), e);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org