AppModule.java
public static void contributeServiceOverride( MappedConfiguration, 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(); }}
基本就是上面的样子了。。。