function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Apply Site Template to Visualforce Exception page

I've been banging my head against the wall trying to customize the exception page. I created my own and pointed my site to use it as the exception error page. I modified it so that it should apply my SiteTemplate to it. However, whenever an exception occurs, it still just displays the out of the box "Error: Error occurred while loading a Visualforce page." message with the standard styling, which we definitely do not want for our branded customer site. 


I noticed that if I don't have it apply my SiteTemplate and then really water it down to essentially just text, then it finally displays that text without the styling and message. But as soon as I start adding components or anything else, it reverts back to the Salesforce styling.


Also, if navigate directly to /apex/<myexceptionpage>, the styling works perfectly. It's just when I hit an actual exception and get directed to it that the styling breaks on me.



How do I get around this? I really don't want my exception page showing that styling/message...


So after a lot more trial and error, I've found out that it can get extremely difficult to customize the exception page itself with anything other than the most basic Visualforce code and components. My site template has a sidebar and breadcrumb component to it that for whatever reason causes my template to be completely stripped whenever an exception is thrown.


The craziest part is that for a little while, the template was being applied again, but it suddenly just went away and started getting stripped out once again even though I made no changes. It's like if Salesforce detects anything even slightly weird, it reverts to the default exception page with its styling.


My solution was to just remove the template and then duplicate most of the styling the template was doing onto the exception page itself. As long as I excluded the sidebar and breadcrumb components, the exception page always renders my customized version.