11

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 sent.

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

7
+300

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.


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.

3

Ralph,

One of the things to check is if the Send Apex Warning Emails checkbox is checked on the respective User record for those specific Users within your Salesforce instance.

Also as per this Knowledgebase Article,

The Send Apex Warning Emails settings on the User record only controls whether or not you get Apex warning emails every time that an Apex surpasses more than 50% of allocated governor limit. This is available in DE, EE and UE Editions only.

Other thing to note as per this Knowledgebase Article is

Unhandled exception emails are sent by default to the developer specified in the LastModifiedBy field on the failing class or trigger. In addition, you can have emails sent to users of your Salesforce org and to arbitrary email addresses.

To set up these email notifications within your Salesforce instance, from Setup, enter Apex Exception Email in the Quick Find box, then select Apex Exception Email. You can either add existing Salesforce Users or you can include external email addresses who can be notified in case of exception emails. You can also configure Apex exception emails using the Tooling API object ApexEmailNotification.

  • 3
    high quality answer, but looking for cases where these aren't sent if they are set up correctly, meaning apex exception email. what i'm looking at is the documentation gives you the expectation once you set things up you should always get an exception email, but i frequently and irrefutably find that doesn't always happen (i.e. i create a method that throws an exception, call it, it throws it, but i don't get an email) – Ralph Callaway May 31 '18 at 3:49
  • 1
    Are you open to a custom error logging solution? – Jigar Shah May 31 '18 at 6:05
  • 1
    Already did that :), reason I asked the question is this is supposed to work all the time, but seems to have undocumented edge cases. I think the community would benefit from knowing what those are and be broad enough to have experience to know them. Updated the questions to be clearer about the purpose. – Ralph Callaway Jun 1 '18 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.