+ Start a Discussion
Tanu Dua01Tanu Dua01 

we can customize the trigger exception?

we are getting the below error
we can customize the trigger exception and can made this error to user friendly ?
system execution of afterinsert caused by system.dmlexception update failed first exception on row 0 first error field custom validation  exception issue

please help?
Raj VakatiRaj Vakati
yes..  Do it like this below 
 
try {

}catch(Exception e){
throw new Exception(You can't do that here');

}

 
Raj VakatiRaj Vakati
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_exception_custom.htm
Tanu Dua01Tanu Dua01
H Raj,

But i think its not best practice using the try catch in the Trigger