Salesforce Certified Platform Developer free question 6 / 10 · Domain 2: Process Automation and Logic
An Apex class that runs overnight hits an unhandled exception. Which statement about how this exception is reported matches the Apex Developer Guide?
- An email containing the exception details goes, by default, to the user who ran the process
- No email is sent. An unhandled exception is recorded just in the debug log
- An email containing the exception details goes, by default, to the developer who last modified the class that failed
- An email containing the exception details is sent every time the same exception occurs, even repeatedly
Show the answer and explanation
Answer: C
Why this is correct
The topic "Exceptions in Apex" says that for unhandled exceptions, meaning exceptions the code does not catch, Salesforce sends an email that includes the exception information. By default the email goes to the developer named in the LastModifiedBy field of the failing class or trigger. Under Apex Exception Email in Setup, other users or any email addresses can be added as recipients.
Why the other options are wrong
"An email containing the exception details goes, by default, to the user who ran the process" … The guide says the unhandled exception email goes, by default, to the developer in the LastModifiedBy field of the failing class or trigger. The user who ran the process is not the default recipient.
"No email is sent. An unhandled exception is recorded just in the debug log" … The exception is also written to the debug log, but for unhandled exceptions Salesforce also sends an email with the exception information.
"An email containing the exception details is sent every time the same exception occurs, even repeatedly" … When the same exception keeps occurring, emails after the first are suppressed and only the first one is sent. This keeps the developer's inbox from filling up with the same error.
Takeaway
No email is sent for anonymous Apex or for exceptions in methods called through @AuraEnabled from Aura or LWC. Emails are limited to 10 per hour per application server and are not guaranteed to arrive. When an exception stops processing, the DML done up to that point is rolled back.