You need to sign in to do that
Don't have an account?

trapping errors thrown by validation rules in a trigger
I have a trigger that occasionally throws an error due to a validation rule. I have a try/catch block in my trigger, but the validation rule isn't caught in the catch block. Is there a way to gracefully handle the error thrown by the validation rule when the trigger fires?
If there is no way to trap for the validation rule errors in a trigger, can anyone explain why? Currently, a big red apex error message is generated, which is not very user friendly to the end-user. I'm just trying to handle the error gracefully, if possible.
Thanks for any help.
The trigger fires on the OpportunityLineItem, but the validation error is occurring on the Opportunity which is the object I'm updating. The try/catch doesn't trap the validation rule that is getting thrown on the Opportunity when the update occurs. I've found a workaround, but I'm interested in someone else can successfully trap validation rule errors in this type of scenario?
I am experiencing the same issue with a trigger that fires when a custom object is updated and it tries to update some opportunities that meet a validation rule. Can you share how you solved this?
Thanks!