...
Code Block |
---|
public final class MyRequestCycle extends WebRequestCycle { /** * MyRequestCycle constructor * * @param application the web application * @param request the web request * @param response the web response */ public WebRequestCycle(final WebApplication application, final WebRequest request, final Response response) { super(application, request, response); } /** * {@inheritDoc} */ @Override protected final Page onRuntimeException(final Page cause, final RuntimeException e) { // obviously you can check the instanceof the exception and return the appropriate page if desired return new MyExceptionPage(e); } } |
...
Code Block |
---|
getSession().error(message); throw new RestartResponseException(MyErrorPage.class, optionalPageParameters); // use RestartResponseAtInterceptPageException(MyErrorPage.class); // instead to interrupt current request processing and immediately redirect to an intercept page // it may be tempting to do the following, but it should not be done: // error(message); // setResponsePage(MyErrorPage.class); // Why not? // What about this; will it work? (My experience says no, but I don't know why not.) // getSession().error(message); // setRedirect(true); // setResponsePage(MyErrorPage.class); |
...