You need to sign in to do that
Don't have an account?
Handle exceptions in Apex
Hi,
I have a function where if certain conditions are met I need to display an error message to the end user in red text. Kind of like the standard error message by salesforce, but instead I get the very verbose one.
Any ideas how I can throw error messsage on the user's screen?
Here is my code snippet:
public static void checkChangeAssetSubscribers(Change_Asset__c[] chgAssets) {
for (Change_Asset__c cass:chgAssets) {
if(isAssetsDup(cass, chgAssets)){
System.debug('Duplicate Assets detected!');
cass.Assets__c.addError('This Asset is already associated with the Change.');
//throw new CustomException('You cant do that!!!');
//return;
}
.
.
.
.
.
Thank you
<apex:outputText id="errDbg" value="{!error}" style="font-weight:bold;color:red;" ></apex:outputText> public string error {get;set;}