You need to sign in to do that
Don't have an account?
Suresh Raghuram
how to catch particular exception
when there are many dml statements and if the error or exception occoured , how could we catch that particular exception and show to the user.
Any code snippet or suggestion is a lot appricated.
Hi,
Try the below code snippet as reference:
try{
update account;
} catch (DMLException e){
ApexPages.addMessages(e);
Messaging.SingleEmailMessagemail=new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'developer@acme.com'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('developer@acme.com');
mail.setSenderDisplayName('Apex error message');
mail.setSubject('Error from Org : ' + UserInfo.getOrganizationName());
mail.setPlainTextBody(e.getMessage());
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
For more detail follow the below link:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_exception_methods.htm
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.