When are unhandled exception emails suppressed and not sent? or Why do I not always get exception emails even though I’ve set them up?

The Background

According to the help docs

When unhandled Apex exceptions occur, emails are sent that include the
Apex stack trace and the customer’s org and user ID.

However I frequently encounter times when these emails are not sent (i.e. I generated it, or a user sends me a screenshot of something that should have generated an error).

According to the help docs

If duplicate exceptions occur in Apex code that runs synchronously,
subsequent exception emails are suppressed and only the first email is

So at least in the case of duplicates (whatever that’s defined) as the emails aren’t sent, but the docs don’t mention anything else and this seems to happen far more often than I like given how much I’m counting on this mechanism to allow me to identify major code issues.

The Question

In what other cases would the unhandled exception email not get sent to the emails listed in the Apex Exception Email section of setup? And in the case of duplicates what counts as a duplicate? Given the importance of exception handling it would be incredibly helpful to the community to understand when you can’t count on apex exception emails to reliably alert you to code issues. Authoritative sources greatly appreciated.

NB Please assume things are configured correctly, i.e. email deliverablity is on, you’ve added your email to the apex exception email list, and you get apex exception emails, but not always


Found this interesting statement in the idea Need a reliable developer script exception alert mechanism:

Salesforce R&D has acknowledged the issue but states it is a feature frozen area therefore, there is no known issue is being worked on. R&D is planning to replace this feature with full-featured exception handling/notification/management system.

Unfortunately there isn’t a case number that could provide further reference around that statement.

There is also the known issue Single error email would be sent out for all identical unhandled Apex exception:

“The developer specified in the LastModifiedBy field receives the error via email with the Apex stack trace and the customer’s organization and user ID. No other customer data is returned with the report. Note that for Apex code that runs synchronously, some error emails may get suppressed for duplicate exception errors.”

However, the Salesforce framework may suppress additional emails not mentioned here. Only one error email is sent out for all identical unhandled Apex exceptions

That certainly suggests that there are scenarios where “identical” exceptions will be suppressed. Unfortunately, that just moves the question down to defining what makes two exceptions identical.

September 2020 update:

Another Known Issue has been acknowledged – Missing Unhandled Apex Exceptions Emails.

Sometimes customers will not receive all of the expected Apex Exception Emails when a runtime unhandled exception occurs in their code.
There is an instance-wide limit of a few hundred exception emails per hour. Because of this, the exception email quota can be used by few orgs on the instance, depriving other orgs from receiving all of the exception emails occurring in the same hour.

So, even with the an entirely new and unseen exception, you might not get the error email if other tenant orgs are throwing lots of errors.

I’ve asked around a few sources. For a number of reasons you are unlikely to get a better answer around exactly how it works (or doesn’t in some cases). Unfortunately that includes what constitutes an exception that will get suppressed.

Voting for the idea above is currently the best course of action for improving the current exception reporting mechanism long term.

Source : Link , Question Author : Ralph Callaway , Answer Author : Daniel Ballinger

Leave a Comment