function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SkyBlue2007SkyBlue2007 

Exception handling except for some User Validation Rules.

Hi all,

 

I'm thinking of Exception handling except for some User Validation Rules,

but Apex catches an Exception with them.

 

Here's Apex.

try {
   update user;
}
catch (Exception e) {
   String errorMessage = e.getMessage();
   ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, errorMessage));
}

 In this case, I have two error messages.

 

Thanks,

SkyBlue2007

 

 

_Prasu__Prasu_

Checkout following wiki link: 

 

http://wiki.developerforce.com/index.php/An_Introduction_to_Exception_Handling

 

I hope this will help.

SkyBlue2007SkyBlue2007

Hi eprasu,

 

Thank you for your prompt reply.

Based on your suggestion, I added some sentences in Apex.

try {
   update user;
}
catch (Exception e) {
   String errorMessage = e.getMessage();
   if(!errorMessage.contains('FIELD_CUSTOM_VALIDATION_EXCEPTION')) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, errorMessage));
   }
}

 

Thanks,

Seiji