[SalesForce] Custom error message for workflow rule

I want to display a custom error message if my workflow rule fires and fails. Basically, I am trying to avoid duplicate dates. I have got my workflow running, but right now it displays the following message:

"duplicate value found: Unique_Key__c duplicates value on record with id: a04j0000002bTQs"

Is it possible to display a different message such as:

"This date already exists in a record."

Any help is highly appreciated! Thanks!

Best Answer

You can do following

1) Write controller and override the Save method
2) In save method use try cache block and show whatever message your want to show

    update myObj;
catch(Exception exc)
        Trigger.new[0].addError('Please select only active entities.');