commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/digester/src/java/org/apache/commons/digester Digester.java
Date Mon, 16 Dec 2002 02:14:16 GMT
craigmcc    2002/12/15 18:14:16

  Modified:    digester/src/java/org/apache/commons/digester Digester.java
  Log:
  When an exception is thrown by a Rule, it is normally wrapped in a
  SAXException and rethrown.  Now, if the original exception was actually an
  InvocationTargetException (such as what might be thrown by a property setter
  called via BeanUtils.setProperty()), the InvocationTargetException will be
  unwrapped first before being rewrapped as a SAXException.  This should
  lead to more intelligible stack traces.
  
  PR: Bugzilla #14415
  Submitted by: Karl von Randow <karl at xk72.com>
  
  Revision  Changes    Path
  1.69      +18 -4     jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java
  
  Index: Digester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- Digester.java	2 Oct 2002 19:23:12 -0000	1.68
  +++ Digester.java	16 Dec 2002 02:14:15 -0000	1.69
  @@ -70,6 +70,7 @@
   import java.io.IOException;
   import java.io.PrintWriter;
   import java.io.Reader;
  +import java.lang.reflect.InvocationTargetException;
   import java.net.URL;
   import java.net.URLConnection;
   import java.util.ArrayList;
  @@ -2368,6 +2369,13 @@
        * @return the new exception
        */
       protected SAXException createSAXException(String message, Exception e) {
  +        if ((e != null) &&
  +            (e instanceof InvocationTargetException)) {
  +            Throwable t = ((InvocationTargetException) e).getTargetException();
  +            if ((t != null) && (t instanceof Exception)) {
  +                e = (Exception) t;
  +            }
  +        }
           if (locator != null) {
               String error = "Error at (" + locator.getLineNumber() + ", "
                       + locator.getColumnNumber() + ": " + message;
  @@ -2392,6 +2400,12 @@
        * @return the new exception
        */
       protected SAXException createSAXException(Exception e) {
  +        if (e instanceof InvocationTargetException) {
  +            Throwable t = ((InvocationTargetException) e).getTargetException();
  +            if ((t != null) && (t instanceof Exception)) {
  +                e = (Exception) t;
  +            }
  +        }
           return createSAXException(e.getMessage(), e);
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message