I am trying to define a generic error handling for my apex application. I have my try/catch blocks in controllers/extensions at various methods. I am able to check and catch business logic related exceptions ( and all other checked exceptions ). My question is related to unhandled or run time exceptions.

Is there a way to handle run time exceptions at a central level and show a generic error page (instead of system error page shown at present). Error handling needs to be elegant.

I know of similar features in java but was wondering if any such feature is available in apex as well.

Any pointers will be greatly appreciated.


You should be able to "predict" some of the run-time exceptions related to the platform governor limits by using the Limits Class, however I haven't seen anything yet that allows to handle a generic run-time exception.

  • Thanks for the answer. I am referring to generic error page which can be shown for anything that goes unhandled. Checking Limits and doing thorough code review will help in identifying probable exception scenarios but is not feasible for whole code base. – Dave Aug 17 '15 at 4:23
  • At this point in time you can only customize Site/Community Error pages, but not the internal ones. Apparently it's on the roadmap (since 2008) and it's highly prioritized as per the first answer here - developer.salesforce.com/forums/?id=906F000000094JPIAY . – Boris Bachovski Aug 17 '15 at 4:29

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.