0

I recently am developing a code to insert custom records. Based on this insert it will trigger many apex classes. There can be some issues with other Apex classes when they get executed. So i handle them with a try catch block. Here is the code

try{ 
    insert customRecordsList; 
}
catch(DMLException ex){ 
    system.debug('comes here1');
    processFailedRecords(someListOfRecords);
    ExMessage = new Notification(Notification__c = 'DML Error', Detailed_message__= ex.Message)
    insert ExMessage;
    system.debug('comes here2');
}

So, my issue here is, when a DML Exception is thrown it catches the exception correctly and insert the ExMessage (ExMessage is another custom record). But it won't execute either processFailedRecords() method or system.debug() lines. Have I missed anything here? What is the reason not to execute these lines?

  • Kindly share the code of "processFailedRecords( )" method. – Mahmood Nov 17 '16 at 7:47
  • It may have something to do with your logging levels, meaning you just don't see the methods being called from the debug log. – rael_kid Nov 17 '16 at 7:52
  • You mean do we need to have a different log level to see debug logs inside the Catch block. – L Mudiyanse Nov 17 '16 at 8:21
  • @mahmood what inside processFailedRecords () does is update some certain records. Not sure how that would impact the issue – L Mudiyanse Nov 17 '16 at 8:24
  • You said that records are being inserted successfully into "ExMessage" object but not into the processFailedRecords. So, the thing to see, what is going on in there? Second, you need to check your system.debug logging levels and see if you have enabled debug logs for your user. – Mahmood Nov 17 '16 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.