1

I am using Salesforce community. The code was running fine until recently. But, now if I open the same page I get the Exception page sying Error Occured While Loading the Page. When I check into debug, I am not able to understand what went wrong. I am not sure what the problem is. Or is there any way to atleast get the error message ?

  • Issue could be due to different problems, like null pointer, etc. Try opening same page as a admin, otherwise comment few lines of code in your controller to drill down the issue further. – Raul Feb 16 '17 at 9:36
2

When you create community you will get an Generic Excption page.

Edit the exception page and Change Site.Errormessage to Site.Errordescription and you will get actual message.

<apex:outputText styleClass="title" value="{!$Label.site.error}">
        <apex:param value="{!$Site.ErrorMessage}"/>
                   <!-- this parameter needs to be italic in the site.error label -->
</apex:outputText>

change this into

<apex:outputText styleClass="title" value="{!$Label.site.error}">
      <apex:param value="{!$Site.ErrorDescription}"/>
                   <!-- this parameter needs to be italic in the site.error label -->
</apex:outputText>

And from Winter 17 you need to set cookies to get proper debugs for guest user

  • Execute a command to set the cookie. If you use a .force.com domain, use this command.

    document.cookie="debug_logs=debug_logs;domain=.force.com";

  • If you use a custom domain (for example, yourCustomDomain.com), use this command.

    document.cookie="debug_logs=debug_logs;domain=yourCustomDomain.com";

1


I have written a blog post for troubleshooting such scenario, there are standard error pages for communities which we can override using custom vf pages to catch the exceptions and show the actual exception message which will be userfriendly.

Two options available on Force.com sites which gives the exact reason the particular error has pop-up are
$Site.ErrorMessage : Returns an error message for the current page if it’s a designated error page for the site and an error exists; otherwise, returns an empty string.
$Site.ErrorDescription : Returns an error message for the current page if it’s a designated error page for the site and an error exists; otherwise, returns an empty string.
Ref: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_global_site.htm

Please refer following link this might help you to mitigate the issue, it has all the steps covered to create custom generic exception page.

Since this is a custom error page you can also customize this as per your need also you can handle different conditions (if there any) at controller side which adds more flexibility.

Error occurred while loading a Visualforce page http://rubberduckingwithnachiket.blogspot.in/2017/01/error-occurred-while-loading.html

VisualforcePage : CustomErrorPage

<apex:page action="{!yourPageLevelAction}" controller="YourController" >
   <apex:outputText styleClass="title" value="{!failingPageResponse}">   </apex:outputText>
</apex:page>

Controller : YourController

public  class YourController {
    //Variable Declaration
    public String failingPageResponse { get; set; }

    public PageReference yourPageLevelAction()
   {
      failingPageResponse = Site.getErrorDescription();
      return null;
    }//yourPageLevelAction
}//YourController

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.