martinc     02/03/10 20:56:53

  Modified:    src/share/org/apache/struts/taglib/template GetTag.java
                        InsertTag.java
  Log:
  Clean up exception handling so that we don't catch what we don't mean to,
  and we encapsulate what we do catch when we rethrow.
  
  Revision  Changes    Path
  1.11      +13 -9     
jakarta-struts/src/share/org/apache/struts/taglib/template/GetTag.java
  
  Index: GetTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/GetTag.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- GetTag.java       29 Apr 2001 05:59:58 -0000      1.10
  +++ GetTag.java       11 Mar 2002 04:56:53 -0000      1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/GetTag.java,v 
1.10 2001/04/29 05:59:58 craigmcc Exp $
  - * $Revision: 1.10 $
  - * $Date: 2001/04/29 05:59:58 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/GetTag.java,v 
1.11 2002/03/11 04:56:53 martinc Exp $
  + * $Revision: 1.11 $
  + * $Date: 2002/03/11 04:56:53 $
    *
    * ====================================================================
    *
  @@ -60,8 +60,10 @@
    */
   package org.apache.struts.taglib.template;
   
  +import java.io.IOException;
   import java.util.Hashtable;
   import java.util.Stack;
  +import javax.servlet.ServletException;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
  @@ -75,7 +77,7 @@
    * it, depending upon the value of the content's direct attribute.
    *
    * @author David Geary
  - * @version $Revision: 1.10 $ $Date: 2001/04/29 05:59:58 $
  + * @version $Revision: 1.11 $ $Date: 2002/03/11 04:56:53 $
    */
   public class GetTag extends TagSupport {
   
  @@ -177,9 +179,9 @@
               try {
                  pageContext.getOut().print(content.toString());
               }
  -            catch(java.io.IOException ex) {
  +            catch(IOException ex) {
                  saveException(ex);
  -               throw new JspException(ex.getMessage());
  +               throw new JspException(ex);
               }
            }
            else {
  @@ -187,10 +189,12 @@
                  if (flush)
                     pageContext.getOut().flush();
                  pageContext.include(content.toString());
  -            }
  -            catch(Exception ex) { 
  +            } catch (IOException ex) {
  +              saveException(ex);
  +              throw new JspException(ex);
  +            } catch(ServletException ex) {
                  saveException(ex);
  -               throw new JspException(ex.getMessage());
  +               throw new JspException(ex);
               }
            }
         }
  
  
  
  1.10      +11 -7     
jakarta-struts/src/share/org/apache/struts/taglib/template/InsertTag.java
  
  Index: InsertTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/InsertTag.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- InsertTag.java    13 Jan 2002 00:25:37 -0000      1.9
  +++ InsertTag.java    11 Mar 2002 04:56:53 -0000      1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/InsertTag.java,v 
1.9 2002/01/13 00:25:37 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2002/01/13 00:25:37 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/InsertTag.java,v 
1.10 2002/03/11 04:56:53 martinc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2002/03/11 04:56:53 $
    *
    * ====================================================================
    *
  @@ -60,8 +60,10 @@
    */
   package org.apache.struts.taglib.template;
   
  +import java.io.IOException;
   import java.util.Hashtable;
   import java.util.Stack;
  +import javax.servlet.ServletException;
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.TagSupport;
  @@ -75,7 +77,7 @@
    * tags, which are accessed by <template:get> in the template.
    *
    * @author David Geary
  - * @version $Revision: 1.9 $ $Date: 2002/01/13 00:25:37 $
  + * @version $Revision: 1.10 $ $Date: 2002/03/11 04:56:53 $
    */
   public class InsertTag extends TagSupport {
   
  @@ -151,10 +153,12 @@
         }
         try {
            pageContext.include(prefix + template);
  -      }
  -      catch(Exception ex) { // IOException or ServletException
  +      } catch (IOException ex) {
  +        saveException(ex);
  +        throw new JspException(ex);
  +      } catch(ServletException ex) {
            saveException(ex);
  -         throw new JspException(ex.getMessage());
  +         throw new JspException(ex);
         }
         ContentMapStack.pop(pageContext);
         return EVAL_PAGE;
  
  
  

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

Reply via email to