mitchspano/apex-trigger-actions-framework

Allow exceptions to be managed outside of framework

LawrenceLoz opened this issue · 2 comments

Expected Behavior

It should be possible to handle a trigger exception higher in the stack with a try/catch

Actual Behavior

Exceptions are caught inside the framework and addError() used, meaning try/catch of a DML operation leading to an exception gives inaccurate feedback to calling context

Steps to Reproduce the Problem

With current framework version and a trigger action throwing an exception, code in catch handler below won't execute:
image

If TriggerBase is changed as below:
image

Exception will be caught in the calling class in the first screenshot.

Assuming you agree this is beneficial, suggest either:

  1. Removing try/catch blocks from TriggerBase
  2. Introducing public static flag (or configuration metadata type) providing option to control whether exceptions are managed through addError() or re-thrown

Specifications

  • Version: Latest
  • Platform: All

Sorry my bad, I was using an out of date version of the codebase. Fetched latest and confirmed this is working as expected with current version. Great stuff!