...
Using Narender Singh’s Exception Message
This is a standard Apex Exception message
But it’s created as a handy Invocable Apex that you can force an error in Flows
https://forcepanda.wordpress.com/2019/12/26/how-to-throw-exceptions-in-flows/
but it’s still UGLY and not acceptable for end users. I use it for debugging though!
...
Apex Errors
And it’s not even just flows. This is an Apex trigger error. Under no circumstances should this ever be seen by the user.
...
There is a Duplicate rule here being hit. So why isn’t the duplicate rule error message only being displayed?
My client came back to me with this:
Hey Jodie, This record is generating an error message I've never seen before. XXX is trying to change the end date and the status to Inactive but a giant error SNAG message appears when trying to save. I'm getting the same experience.
This is what exactly the same duplicate rule looks like when editing the Contact record.
...
WHY can’t this or a similar error message be shown no matter HOW the error ocurred. The Apex code has the context of which record it was trying to update at that time so why can’t it just show a nice error message of “Contact Alex Jones related to this record looks like an existing record. Make sure to check any potential duplicate records before saving. View Duplicates on Alex Jones.”
This is why I generally disable ALL duplicate Alerts (I had missed this one).