In Spring '21 Salesforce released the BatchApexErrorEvent to allow developers to get information on failing batch classes. Get your errors by email or store them in a custom object. Customize your error handling by class.
- Email batch errors to an admin or support team for evaluation and processing
- Store batch errors in a custom object including the class that failed, full stack trace, and the records that were in the batch.
- Deploy the contents of this repo into your org.
- Implement Database.RaisesPlatformEvents on any batch class where you want to add error handling.
- Setup at least one org wide email address
- Setup the Batch Apex Error Settings from the Custom Settings section in Setup