Hi guys, I'm trying to implement a custom exception page for production mode only. Using Jumpstart I was able to get the page to work without issue.
http://jumpstart.doublenegative.com.au/jumpstart/examples/infrastructure/exceptionreportpage http://wiki.apache.org/tapestry/Tapestry5ExceptionPage however I do not know how to use tapestries default exception page during dev. In my old 5.3.7 app, I was able to do something like this. I'm assuming there must be a simpler way in 5.4? public class ErrorReport implements ExceptionReporter { @Property private Throwable exception; public void reportException(Throwable exception) { this.exception = exception; } } public class ProductionExceptionHandler { private final Logger logger; private final ResponseRenderer renderer; private final ComponentSource componentSource; private final static String ERROR_PAGE_NAME = "ErrorReport"; public ProductionExceptionHandler(Logger logger, ResponseRenderer renderer, ComponentSource componentSource) { this.logger = logger; this.renderer = renderer; this.componentSource = componentSource; } public void handle(Throwable exception) throws IOException { //Send email ExceptionReporter errorPage = (ExceptionReporter) componentSource.getPage(ERROR_PAGE_NAME); errorPage.reportException(exception); renderer.renderPageMarkupResponse(ERROR_PAGE_NAME); } } @Match("RequestExceptionHandler") // service to advise @Order("after:requestExceptionHandler") // advice id from tapestry-security SecurityModule public static void adviseProductionExceptionHandler( MethodAdviceReceiver receiver, final Logger logger, final @Symbol(SymbolConstants.PRODUCTION_MODE) boolean productionMode, final ProductionExceptionHandler handler) { Method handleMethod; try { Class<?> serviceInterface = receiver.getInterface(); handleMethod = serviceInterface.getMethod(EXCEPTION_HANDLE_METHOD_NAME, Throwable.class); } catch (Exception e) { throw new RuntimeException("Can't find method RequestExceptionHandler." + EXCEPTION_HANDLE_METHOD_NAME + ". Changed API?", e); } MethodAdvice advice = new MethodAdvice() { public void advise(MethodInvocation invocation) { if (productionMode) { Throwable exception = (Throwable) invocation.getParameter(0); try { handler.handle(exception); } catch (IOException e) { logger.error("Error in ProductionExceptionHandler", e); invocation.proceed(); } } else { invocation.proceed(); } } }; receiver.adviseMethod(handleMethod, advice); } -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York