I am using TriggerFramework
for implementing a trigger on case. When I started writing tests for this trigger, this catch statement isn't covered by the tests:
trigger CaseMain on Case (before insert, before update, after insert, after update) {
try {
TriggerFactory.createAndExecuteHandler(CaseHandler.class);
} catch(Exception ex) {
MilestoneUtils.SendNotificationOnTriggerFailure('CaseMain', ex);
}
}
The rest of the code is executed, but not the catch batch. I tried to insert a record which would throw a SoqlException, NullPointerException, or a DmlException, but none of these covered the code.
TriggerFactory.createAndExecuteHandler
, no exception will ever reach thecatch
block here, and there's no reason for it to exist.