protected Throwable buildView(FacesContext context, Throwable throwable, Throwable rootCause) throws IOException {
        if (context.getViewRoot() == null) {
            ViewHandler viewHandler = context.getApplication().getViewHandler();

            String viewId = viewHandler.deriveViewId(context, ComponentUtils.calculateViewId(context));
            ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, viewId);
            UIViewRoot viewRoot = vdl.createView(context, viewId);
            context.setViewRoot(viewRoot);

            vdl.buildView(context, viewRoot);

            // Workaround for Mojarra
            // if UIViewRoot == null -> 'IllegalArgumentException' is thrown instead of 'ViewExpiredException'
            if (rootCause == null && throwable instanceof IllegalArgumentException) {
                rootCause = new jakarta.faces.application.ViewExpiredException(viewId);
            }
        }

        return rootCause;
    }
Builds the view if not already available. This is mostly required for ViewExpiredException's.

@param context The {@link FacesContext}.
@param throwable The occurred {@link Throwable}.
@param rootCause The root cause.
@return The unwrapped {@link Throwable}.
@throws java.io.IOException If building the view fails.
primefaces/src/main/java/org/primefaces/application/exceptionhandler/PrimeExceptionHandler.java