I'm having problem showing errors in my page, I have validation rule on the custom_object__c which I have created and its Active but when I try to save the page instead of getting the validation rule error on my apex:pageMessages I'm getting Visualforce Error

here is the erorr showing:

System.DmlException: Update failed. First exception on row 0 with id XXXXX; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION ]

Error is in expression '{!Save}' in component in page employeePage: Class.EmployeeCtrl.Save:

What do I need to do to show error on apex:pageMessages?

  • try to use try catch block and check the exception message. ? I guess you will get the above update filed error but also you will get the message.. totally you will get 2 error message.
    – Ratan Paul
    Jun 23, 2016 at 13:27

1 Answer 1


You should try like this :

try {  
    insert Account;
catch (DMLException e) {

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .