Skip to main content

Exception Handling

Another post for future referencing


Adding error handling within a Trigger or database transaction

try{
}catch(DMLException e){
         for (Integer i = 0; i < e.getNumDml(); i++) {
            // Process exception here
                System.debug(e.getDmlMessage(i));
                LineItemList [i].adderror(e.getDmlMessage(i));
        }

     }



Adding error handling within a method


try{
   //work here
 }catch(exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,e.getmessage()));

}  

Comments

Popular posts from this blog

Override Name in the Salesforce Cloud Console

Service Cloud Console HyperLink Opens new window outside of the console, Opens new tab inside the console. HYPERLINK("javascript:if(typeof(srcUp)=='function') {srcUp('/" & Id & "?isdtp=vw');}"+ " else {window.location.href='/" & Id & "'}", User__r.FirstName + ' ' + User__r.LastName, "_self" ) Checks if the srcUp exists and if it does, you're in the console.