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
rishi jaykar 1rishi jaykar 1 

if i got an exception then open a VF page, try catch under my constructor?

Ahmad J. KoubeissyAhmad J. Koubeissy
can you attach the code please
Hi Rishi,

You can use action instead of constructor and redirect to the page in catch segment.

Here is sample code:
VF Page:
<apex:page action="{!redirectAfterException}" controller="exceptionPageCtrl" >
And controller:
public class exceptionPageCtrl {

    public PageReference redirectAfterException() {
            Integer i=0;
            Integer j=1;
        catch(Exception ex)
            return Page.page1;
        return null;


Please let me know if you have any question.

Thanks & Regards
Gulshan Raj