Tapestry ErrorReport

AppModule.java

    public static void contributeServiceOverride(
            MappedConfiguration<Class<?>, Object> configuration,
            @Local RequestExceptionHandler handler)
    {
        configuration.add(RequestExceptionHandler.class, handler);
    }
    
    public RequestExceptionHandler buildRequestExceptionHandler2(final ResponseRenderer renderer,
            final ComponentSource componentSource)
    {
        return new RequestExceptionHandler() {
            public void handleRequestException(Throwable exception) throws IOException
            {
                ExceptionReporter errorPage = (ExceptionReporter) componentSource.getPage("ErrorReporter");
                errorPage.reportException(exception);
                renderer.renderPageMarkupResponse("ErrorReporter");
            }
        };
    }

ErrorReporter.java

public class ErrorReporter implements ExceptionReporter
{

    @Property
    private String errorMessage;

    public void reportException(Throwable exception)
    {
        errorMessage = exception.getMessage();
    }

}

基本就是上面的样子了。。。

posted @ 2013-04-10 16:07  VoctrALs  阅读(197)  评论(0编辑  收藏  举报