Good day everyone, I create a batch process class. The problem I have at the moment, is that how will I check if there is an error encountered during the batch iteration. In my case, I've tried to process a batch with 8 iterations. From 1 to 6 there is no error. But during the 7th iteration, an error occur saying Too many query rows: 50001
. My question is how will I check if some problem occur in the batch ? So far what I've tried are the following.
- I put
try
andcatch
in my executable class and add variable to check if it enter the catch statement.but it seems it is not working.
2.I also try to put system.debug();
inside my finish
class but it seems that when an error occured it will not read the finish
method. I also try to add query in my finish which is something like this:
AsyncApexJob batchResult = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
TotalJobItems, CreatedBy.Email, ExtendedStatus
from AsyncApexJob where Id = :bc.getJobId()];
But still it doesn't work.
What is the best way to fix my problem. Please help.