function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matt BostromMatt Bostrom 

is there a way to suppress email exception in Apex?

hi all,
within a trigger we are adding an error to the record if it meets certain criteria (validation rule won't work in this case so we are forced to do it this way):

object.addError('message here');

this is working fine and erroring out as designed. However this also generates an email exception. In this case we do not want an email exception generated. We have tried TRY/CATCH blocks but it seems that a validation rule with onError isn't being caught and handled in this case. Any ideas how we can suppress this just for this 1 block of code?
pconpcon
As stated in your other question, there is no way to suppress this message.  You could send the error messages to a group email list and filter them out based on some criteria prior to being delivered.  Your other option is to not use addError for email-to-case.