Allow exceptions to be managed outside of framework
LawrenceLoz opened this issue · 2 comments
LawrenceLoz commented
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:
If TriggerBase is changed as below:
Exception will be caught in the calling class in the first screenshot.
Assuming you agree this is beneficial, suggest either:
- Removing try/catch blocks from TriggerBase
- 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
LawrenceLoz commented
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!
mitchspano commented
Lol glad to help Lawrence!
…On Fri, Apr 23, 2021 at 4:55 AM Lawrence Newcombe ***@***.***> wrote:
Closed #45
<#45>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#45 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEMMZIATYJTRRDRI4DZMGU3TKE7YFANCNFSM43OJOZXQ>
.