use of org.apache.wicket.markup.html.pages.ExceptionErrorPage in project syncope by apache.
the class SyncopeConsoleRequestCycleListener method onException.
@Override
public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
LOG.error("Exception found", e);
PageParameters errorParameters = new PageParameters();
IRequestablePage errorPage = null;
if (instanceOf(e, UnauthorizedInstantiationException.class) != null) {
errorParameters.add("errorMessage", MISSING_AUTHORIZATION);
errorPage = new Login(errorParameters);
} else if (instanceOf(e, AccessControlException.class) != null) {
if (instanceOf(e, AccessControlException.class).getMessage().contains("expired")) {
errorParameters.add("errorMessage", PAGE_EXPIRED);
} else {
errorParameters.add("errorMessage", MISSING_AUTHORIZATION_CORE);
}
errorPage = new Login(errorParameters);
} else if (instanceOf(e, PageExpiredException.class) != null || !SyncopeConsoleSession.get().isSignedIn()) {
errorParameters.add("errorMessage", PAGE_EXPIRED);
errorPage = new Login(errorParameters);
} else if (instanceOf(e, BadRequestException.class) != null || instanceOf(e, WebServiceException.class) != null || instanceOf(e, SyncopeClientException.class) != null) {
errorParameters.add("errorMessage", REST);
errorPage = new Login(errorParameters);
} else {
Throwable cause = instanceOf(e, ForbiddenException.class);
if (cause == null) {
// redirect to default Wicket error page
errorPage = new ExceptionErrorPage(e, null);
} else {
errorParameters.add("errorMessage", cause.getMessage());
errorPage = new Login(errorParameters);
}
}
if (errorPage instanceof Login) {
try {
SyncopeConsoleSession.get().cleanup();
SyncopeConsoleSession.get().invalidateNow();
} catch (Throwable t) {
// ignore
LOG.debug("Unexpected error while forcing logout after error", t);
}
}
return new RenderPageRequestHandler(new PageProvider(errorPage));
}
use of org.apache.wicket.markup.html.pages.ExceptionErrorPage 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);
}
Aggregations