Clover coverage report - Code Coverage for tapestry release 4.0-alpha-2
Coverage timestamp: Thu May 5 2005 09:57:44 EDT
file stats: LOC: 81   Methods: 4
NCLOC: 40   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ExceptionPresenterImpl.java - 100% 100% 100%
coverage
 1   
 // Copyright 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.tapestry.error;
 16   
 
 17   
 import org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.tapestry.IPage;
 19   
 import org.apache.tapestry.IRequestCycle;
 20   
 import org.apache.tapestry.services.ResponseRenderer;
 21   
 
 22   
 /**
 23   
  * @author Howard M. Lewis Ship
 24   
  * @since 4.0
 25   
  */
 26   
 public class ExceptionPresenterImpl implements ExceptionPresenter
 27   
 {
 28   
     private RequestExceptionReporter _requestExceptionReporter;
 29   
 
 30   
     private ResponseRenderer _responseRenderer;
 31   
 
 32   
     private String _exceptionPageName;
 33   
 
 34  27
     public void presentException(IRequestCycle cycle, Throwable cause)
 35   
     {
 36  27
         try
 37   
         {
 38  27
             IPage exceptionPage = cycle.getPage(_exceptionPageName);
 39   
 
 40  27
             exceptionPage.setProperty("exception", cause);
 41   
 
 42  27
             cycle.activate(exceptionPage);
 43   
 
 44  27
             _responseRenderer.renderResponse(cycle);
 45   
         }
 46   
         catch (Throwable ex)
 47   
         {
 48   
             // Worst case scenario. The exception page itself is broken, leaving
 49   
             // us with no option but to write the cause to the output.
 50   
 
 51  1
             _requestExceptionReporter.reportRequestException(ErrorMessages
 52   
                     .unableToProcessClientRequest(cause), cause);
 53   
 
 54   
             // Also, write the exception thrown when redendering the exception
 55   
             // page, so that can get fixed as well.
 56   
 
 57  1
             _requestExceptionReporter.reportRequestException(ErrorMessages
 58   
                     .unableToPresentExceptionPage(ex), ex);
 59   
 
 60   
             // And throw the exception.
 61   
 
 62  1
             throw new ApplicationRuntimeException(ex.getMessage(), ex);
 63   
         }
 64   
 
 65   
     }
 66   
 
 67  20
     public void setExceptionPageName(String exceptionPageName)
 68   
     {
 69  20
         _exceptionPageName = exceptionPageName;
 70   
     }
 71   
 
 72  19
     public void setRequestExceptionReporter(RequestExceptionReporter requestExceptionReporter)
 73   
     {
 74  19
         _requestExceptionReporter = requestExceptionReporter;
 75   
     }
 76   
 
 77  20
     public void setResponseRenderer(ResponseRenderer responseRenderer)
 78   
     {
 79  20
         _responseRenderer = responseRenderer;
 80   
     }
 81   
 }