} catch (RedirectLoopException e) {
throw e;
} catch (RuntimeException e) {
if (toPageInstance == null)
// This is an extremely unlikely case, so throwing an exception is preferable to going through the navigation error handler.
throw new PageNotFoundException("There is no page of type " + toPage.getName() + " in the navigation graph.");
else
navigationErrorHandler.handleInvalidPageNameError(e, toPageInstance.name());
}
}