You need to sign in to do that
Don't have an account?
Try catch and developer script exception
The organization owner received a developer script exception via email from the production. Please note that I have not access to the production, the owner deployed the change set.
There is a /JSON/ REST integration with an Apex class to receive POST callouts via a Site Guest User. The method throws an Exception (Upsert failed, DUPLICATE_VALUE) and this is correct. A value duplicated in a unique field.
The problem is something else: The full method body is in a try-catch. The line (line 82) that causes the exception is in the try block. Why received the owner the developer script exception email? The salesforce send developer script exception email from handled exception?
Subject: Developer script exception from Természetesen Alapítvány : AccountForContactCreation : AccountForContactCreation: execution of BeforeInsert caused by: System.DmlException: Upsert failed. First exception on row 102; first error: DUPLICATE_VALUE, Duplicate external id specified: XXXXXXXXXXXXXXX: [A_NameExternalId__c] Trigger.AccountForContactCreation: line 82, column 1 To: "info@XXXXXXXXXX.com" <info@XXXXXXXXXX.com> Apex script unhandled trigger exception by user/organization: 0050O00000XXXX/00D2000000XXXXX AccountForContactCreation: execution of BeforeInsert caused by: System.DmlException: Upsert failed. First exception on row 102; first error: DUPLICATE_VALUE, Duplicate external id specified: XXXXXXXXXXXXXXX: [A_NameExternalId__c] Trigger.AccountForContactCreation: line 82, column 1
Thanks in advance,
Krisztian
This user has deployed the program that causes the error or the email of the technical user who has deployed is associated with a group and this user belongs to this group.
Is it possible that there are try catch in code but exceptions are not handled for DMLException or Exception.
May be some other specific exceptions like NullPointerException or CalloutException are mentioned there.
Salesforce send “Developer script exception” on email only in case it was unhandled.
The administrator user deployed the change set, but the (technical) site guest user caused the exception.
I am sorry, could you detail it, please? I think it have to catch the DMLException based on https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_exception_trycatch_example.htm
Could you confirm it, please?
The administrator user deployed the change set, but the (technical) site guest user caused the exception.
What is the email used by this administrator?
Set Recipients of Email Notifications for Unhandled Apex Exceptions:
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.
http://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_apex_exception_emails.htm#rn_apex_exception_emails
https://success.salesforce.com/ideaView?id=08730000000BosLAAS
How it possible that the SF can send developer script exception email about a DMLException from a try block which catches Expetion? The recipient address is not interest.
Its really weird.
As per my experience, email should not come because already catch(Exception ex) is there.
I will keep eye on this question and other community members' response as well.
Thanks