[jboss-cvs] jboss-seam/src/main/org/jboss/seam/util ...
Gavin King
gavin.king at jboss.com
Sat Feb 3 20:13:20 EST 2007
User: gavin
Date: 07/02/03 20:13:20
Modified: src/main/org/jboss/seam/util EJB.java
Log:
redesigned exception handling
Revision Changes Path
1.7 +14 -14 jboss-seam/src/main/org/jboss/seam/util/EJB.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EJB.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/util/EJB.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- EJB.java 2 Feb 2007 07:06:22 -0000 1.6
+++ EJB.java 4 Feb 2007 01:13:20 -0000 1.7
@@ -5,6 +5,7 @@
import javax.ejb.EJBContext;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
+import javax.servlet.ServletException;
public class EJB
@@ -70,28 +71,27 @@
public static Exception getCause(Exception exception)
{
- if ( EJB_EXCEPTION.isInstance(exception) )
- {
+ Throwable cause = null;
try
{
- return (Exception) Reflections.getGetterMethod(EJB_EXCEPTION, "causedByException").invoke(exception);
- }
- catch (Exception x)
+ if ( EJB_EXCEPTION.isInstance(exception) )
{
- return null;
+ cause = (Throwable) Reflections.getGetterMethod(EJB_EXCEPTION, "causedByException").invoke(exception);
}
+ else if (exception instanceof ServletException)
+ {
+ cause = ( (ServletException) exception ).getRootCause();
}
else
{
- try
- {
- return (Exception) exception.getCause();
+ cause = exception.getCause();
+ }
}
catch (Exception x)
{
return null;
}
- }
+ return cause==exception || !(cause instanceof Exception) ? null : (Exception) cause;
}
public static Class[] value(Annotation annotation)
More information about the jboss-cvs-commits
mailing list