1 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 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 public void presentException(IRequestCycle cycle, Throwable cause) 37 { 38 try 39 { 40 IPage exceptionPage = cycle.getPage(_exceptionPageName); 41 42 exceptionPage.setProperty("exception", cause); 43 44 cycle.activate(exceptionPage); 45 46 _responseRenderer.renderResponse(cycle); 47 } 48 catch (Throwable ex) 49 { 50 53 _requestExceptionReporter.reportRequestException(ErrorMessages 54 .unableToProcessClientRequest(cause), cause); 55 56 59 _requestExceptionReporter.reportRequestException(ErrorMessages 60 .unableToPresentExceptionPage(ex), ex); 61 62 64 throw new ApplicationRuntimeException(ex.getMessage(), ex); 65 } 66 67 if (_verbose) 68 _requestExceptionReporter.reportRequestException(ErrorMessages 69 .unableToProcessClientRequest(cause), cause); 70 } 71 72 public void setExceptionPageName(String exceptionPageName) 73 { 74 _exceptionPageName = exceptionPageName; 75 } 76 77 public void setRequestExceptionReporter(RequestExceptionReporter requestExceptionReporter) 78 { 79 _requestExceptionReporter = requestExceptionReporter; 80 } 81 82 public void setResponseRenderer(ResponseRenderer responseRenderer) 83 { 84 _responseRenderer = responseRenderer; 85 } 86 87 public boolean isVerbose() 88 { 89 return _verbose; 90 } 91 92 public void setVerbose(boolean verbose) 93 { 94 _verbose = verbose; 95 } 96 } | Popular Tags |