I had understanding that if batch apex execute
method encounters an uncatchable/uncaught exception, then it stops the batch processing at that particular execution of execute
method and does not execute remaining execute
methods, if any.
However I am seeing exact opposite behaviour and the execution continues even after an exception is thrown in execute
method of apex batch. This behaviour is making handling of errors using ApexBatchErrorEvent
tricky as there are multiple Platform events fired for the same error in different execution of execute
method.
I haven't found documentation explaining this behaviour. Attaching screenshot which displays logs generated for an exception in every execution of execute
method.
Thanks in advance for sharing your insights!!
execute
chunk does not affect execution of later chunks. These all happen regardless.