You need to sign in to do that
Don't have an account?
Mak One
Is there any good way provided by Salesforce to catch Validation Error?
I have seen suggestion with below code for catching Validation Error:
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));
}
}
Is there any better way for this as my custom error message may also contain String: 'FIELD_CUSTOM_VALIDATION_EXCEPTION'
Is there any specific Exception Type provided by Salesforce for Validation Error. Or is there any better way to catch ValidationError?
You can use this way to show a proper error message on validation exception --
Praveen Murugesan
Mark this as best answer if its helps.