| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Seam
Revision: 8908
Author: pete.muir@jboss.org
Date: 04 Sep 2008 09:55:47
Changes:Move exception utils to own class
Files:| ... | ...@@ -5,7 +5,6 @@ | |
| 5 | 5 | import javax.ejb.EJBContext; |
| 6 | 6 | import javax.naming.NameNotFoundException; |
| 7 | 7 | import javax.naming.NamingException; |
| 8 | import javax.servlet.ServletException; | |
| 9 | 8 | |
| 10 | 9 | |
| 11 | 10 | public class EJB |
| ... | ...@@ -69,31 +68,6 @@ | |
| 69 | 68 | return (String) Reflections.invokeAndWrap( Reflections.getMethod(annotation, "name"), annotation ); |
| 70 | 69 | } |
| 71 | 70 | |
| 72 | public static Exception getCause(Exception exception) | |
| 73 | { | |
| 74 | Throwable cause = null; | |
| 75 | try | |
| 76 | { | |
| 77 | if ( EJB_EXCEPTION.isInstance(exception) ) | |
| 78 | { | |
| 79 | cause = (Throwable) Reflections.getGetterMethod(EJB_EXCEPTION, "causedByException").invoke(exception); | |
| 80 | } | |
| 81 | else if (exception instanceof ServletException) | |
| 82 | { | |
| 83 | cause = ( (ServletException) exception ).getRootCause(); | |
| 84 | } | |
| 85 | else | |
| 86 | { | |
| 87 | cause = exception.getCause(); | |
| 88 | } | |
| 89 | } | |
| 90 | catch (Exception x) | |
| 91 | { | |
| 92 | return null; | |
| 93 | } | |
| 94 | return cause==exception || !(cause instanceof Exception) ? null : (Exception) cause; | |
| 95 | } | |
| 96 | ||
| 97 | 71 | public static Class[] value(Annotation annotation) |
| 98 | 72 | { |
| 99 | 73 | return (Class[]) Reflections.invokeAndWrap( Reflections.getMethod(annotation, "value"), annotation ); |
| ... | ...@@ -0,0 +1,33 @@ | |
| 1 | package org.jboss.seam.util; | |
| 2 | ||
| 3 | import javax.servlet.ServletException; | |
| 4 | ||
| 5 | public class Exceptions | |
| 6 | { | |
| 7 | ||
| 8 | public static Exception getCause(Exception exception) | |
| 9 | { | |
| 10 | Throwable cause = null; | |
| 11 | try | |
| 12 | { | |
| 13 | if ( EJB.EJB_EXCEPTION.isInstance(exception) ) | |
| 14 | { | |
| 15 | cause = (Throwable) Reflections.getGetterMethod(EJB.EJB_EXCEPTION, "causedByException").invoke(exception); | |
| 16 | } | |
| 17 | else if (exception instanceof ServletException) | |
| 18 | { | |
| 19 | cause = ( (ServletException) exception ).getRootCause(); | |
| 20 | } | |
| 21 | else | |
| 22 | { | |
| 23 | cause = exception.getCause(); | |
| 24 | } | |
| 25 | } | |
| 26 | catch (Exception x) | |
| 27 | { | |
| 28 | return null; | |
| 29 | } | |
| 30 | return cause==exception || !(cause instanceof Exception) ? null : (Exception) cause; | |
| 31 | } | |
| 32 | ||
| 33 | } |