Clover coverage report - Code Coverage for tapestry release 4.0-beta-12
Coverage timestamp: Sun Oct 30 2005 16:22:01 EST
file stats: LOC: 96   Methods: 6
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ExceptionPresenterImpl.java 100% 93.3% 83.3% 91.3%
coverage 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    private boolean _verbose;
 35   
 36  22 public void presentException(IRequestCycle cycle, Throwable cause)
 37    {
 38  22 try
 39    {
 40  22 IPage exceptionPage = cycle.getPage(_exceptionPageName);
 41   
 42  22 exceptionPage.setProperty("exception", cause);
 43   
 44  22 cycle.activate(exceptionPage);
 45   
 46  22 _responseRenderer.renderResponse(cycle);
 47    }
 48    catch (Throwable ex)
 49    {
 50    // Worst case scenario. The exception page itself is broken, leaving
 51    // us with no option but to write the cause to the output.
 52   
 53  1 _requestExceptionReporter.reportRequestException(ErrorMessages
 54    .unableToProcessClientRequest(cause), cause);
 55   
 56    // Also, write the exception thrown when redendering the exception
 57    // page, so that can get fixed as well.
 58   
 59  1 _requestExceptionReporter.reportRequestException(ErrorMessages
 60    .unableToPresentExceptionPage(ex), ex);
 61   
 62    // And throw the exception.
 63   
 64  1 throw new ApplicationRuntimeException(ex.getMessage(), ex);
 65    }
 66   
 67  21 if (_verbose)
 68  3 _requestExceptionReporter.reportRequestException(ErrorMessages
 69    .unableToProcessClientRequest(cause), cause);
 70    }
 71   
 72  17 public void setExceptionPageName(String exceptionPageName)
 73    {
 74  17 _exceptionPageName = exceptionPageName;
 75    }
 76   
 77  16 public void setRequestExceptionReporter(RequestExceptionReporter requestExceptionReporter)
 78    {
 79  16 _requestExceptionReporter = requestExceptionReporter;
 80    }
 81   
 82  17 public void setResponseRenderer(ResponseRenderer responseRenderer)
 83    {
 84  17 _responseRenderer = responseRenderer;
 85    }
 86   
 87  0 public boolean isVerbose()
 88    {
 89  0 return _verbose;
 90    }
 91   
 92  3 public void setVerbose(boolean verbose)
 93    {
 94  3 _verbose = verbose;
 95    }
 96    }