Rich,

Can u please be careful?

import com.ibm.jvm.util.ByteArrayOutputStream;

thanks,
dims

On 11/16/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Author: scheu
Date: Thu Nov 16 13:44:39 2006
New Revision: 475935

URL: http://svn.apache.org/viewvc?view=rev&rev=475935
Log:
AXIS2-1712
Contributor: Mike Rheinheimer
Added support for handling local Throwable (vs. Exception).  Added smart 
processing to exception factory to generate a better message.

Modified:
    
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
    
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java

Modified: 
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java?view=diff&rev=475935&r1=475934&r2=475935
==============================================================================
--- 
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
 Thu Nov 16 13:44:39 2006
@@ -17,12 +17,11 @@

 package org.apache.axis2.jaxws;

+import java.io.PrintStream;
 import java.lang.reflect.InvocationTargetException;

 import javax.xml.ws.ProtocolException;
 import javax.xml.ws.WebServiceException;
-import javax.xml.ws.http.HTTPException;
-import javax.xml.ws.soap.SOAPFaultException;

 import org.apache.axis2.AxisFault;
 import org.apache.axis2.jaxws.i18n.Messages;
@@ -31,6 +30,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

+import com.ibm.jvm.util.ByteArrayOutputStream;
+
 /**
   * ExceptionFactory is used to create exceptions within the JAX-WS 
implementation.
   * There are several reasons for using a factory to create exceptions.
@@ -216,6 +217,15 @@
                }
                rootCause = rootCause==null ? t :rootCause;
                WebServiceException e = null;
+
+        String enhancedMessage = enhanceMessage(rootCause);
+        if (enhancedMessage != null) {
+            if (message != null)
+                message.concat(": " + enhancedMessage);
+            else
+                message = enhancedMessage;
+        }
+
         if (message != null) {
                e =new WebServiceException(message, rootCause);
         } else {
@@ -368,6 +378,30 @@
                }
        }
        return t;
+    }
+
+    /**
+     * Other developers may add additional criteria to give better
+     * error messages back to the user.
+     *
+     * @param t Throwable
+     * @return String a message that helps the user understand what caused the 
exception
+     */
+    private static String enhanceMessage(Throwable t) {
+        if (t == null)
+            return null;
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        PrintStream ps = new PrintStream(baos, true);
+        t.printStackTrace(ps);
+        String stackTrace = baos.toString();
+
+        // TODO better criteria
+        if ((t instanceof StackOverflowError) && (stackTrace.contains("JAXB")))
+            // TODO better message
+            return "The system threw a StackOverflowError at the JAXB level.  This 
usually means there is a circular type reference in the WSDL.";
+
+        return null;
     }

 }

Modified: 
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?view=diff&rev=475935&r1=475934&r2=475935
==============================================================================
--- 
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
 Thu Nov 16 13:44:39 2006
@@ -601,10 +601,11 @@

             // Invoke the OperationClient
             opClient.execute(block);
-        } catch (Exception e) {
-            // Catch all exceptions (including runtime exceptions) and
+        } catch (Throwable e) {
+            // Catch all Throwable (including runtime exceptions and Errors) 
and
             // throw as AxisFault.
-            throw AxisFault.makeFault(e);
+            // Since e could be a Throwable (or Error) instead of an 
Exception, we'll have to wrap it:
+            throw 
AxisFault.makeFault(ExceptionFactory.makeWebServiceException(e));
         } finally {
             // Post-Execute logging and setup
             postExecute(opClient, block, msgContext);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service Developers)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to