Search in sources :

Example 6 with ErrorCodeRequestHandler

use of org.apache.wicket.request.http.handler.ErrorCodeRequestHandler in project wicket by apache.

the class DefaultExceptionMapper method mapUnexpectedExceptions.

/**
 * Maps unexpected exceptions to their corresponding {@link IRequestHandler}.
 *
 * @param e
 * 			the current exception
 * @param application
 * 			the current application object
 * @return the {@link IRequestHandler} for the current exception
 */
protected IRequestHandler mapUnexpectedExceptions(Exception e, final Application application) {
    final ExceptionSettings.UnexpectedExceptionDisplay unexpectedExceptionDisplay = application.getExceptionSettings().getUnexpectedExceptionDisplay();
    logger.error("Unexpected error occurred", e);
    if (ExceptionSettings.SHOW_EXCEPTION_PAGE.equals(unexpectedExceptionDisplay)) {
        Page currentPage = extractCurrentPage();
        return createPageRequestHandler(new PageProvider(new ExceptionErrorPage(e, currentPage)));
    } else if (ExceptionSettings.SHOW_INTERNAL_ERROR_PAGE.equals(unexpectedExceptionDisplay)) {
        return createPageRequestHandler(new PageProvider(application.getApplicationSettings().getInternalErrorPage()));
    }
    // IExceptionSettings.SHOW_NO_EXCEPTION_PAGE
    return new ErrorCodeRequestHandler(500);
}
Also used : ExceptionErrorPage(org.apache.wicket.markup.html.pages.ExceptionErrorPage) ErrorCodeRequestHandler(org.apache.wicket.request.http.handler.ErrorCodeRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) ExceptionErrorPage(org.apache.wicket.markup.html.pages.ExceptionErrorPage) ExceptionSettings(org.apache.wicket.settings.ExceptionSettings)

Aggregations

ErrorCodeRequestHandler (org.apache.wicket.request.http.handler.ErrorCodeRequestHandler)6 IRequestHandler (org.apache.wicket.request.IRequestHandler)4 PackageResource (org.apache.wicket.request.resource.PackageResource)2 Test (org.junit.Test)2 UnauthorizedInstantiationException (org.apache.wicket.authorization.UnauthorizedInstantiationException)1 PageProvider (org.apache.wicket.core.request.handler.PageProvider)1 ExceptionErrorPage (org.apache.wicket.markup.html.pages.ExceptionErrorPage)1 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)1 ExceptionSettings (org.apache.wicket.settings.ExceptionSettings)1