Exception logging
As discussed in Chapter 2, Debugging Apex, gathering information and debugging exceptions in Apex can be difficult. By default, Apex comes with no long-term persistent logging or exception handling framework. As a developer or administrator, you will receive emails when certain exceptions occur within the system, however, they often lack any context or the detailed information needed to rectify the error correctly.
In this section, we are going to construct a very basic error logging framework to enable you to persist exceptions and errors to the database in order to obtain additional information. We are also going to discuss some ways of capturing application state for review to help in this.
Of primary importance with this framework will be logging our exceptions in a persistent manner for us to inspect at a later date.
For this reason, we will create a custom object, Log__c
, which will hold the details of the exception (or any other logs) that we want...