function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
boliset kumarboliset kumar 

Logging exceptions in custom object

Helo,

I am trying to log the exceptions in an custom object ,but after throwing an exception entire transaction is rolled back and i am not able to see in the custom objecy any help would be if great help  for example 

List<IBA_Store_Log__c> ibaLogs = New List<IBA_Store_Log__c>(); 
try {
    integer x = 1/0;
} catch (exception e) {
     IBA_Store_Log__c priceLog = IBA_store_datatableHelper.createIbaLog('ERROR', e.getmessage() + e.getlinenumber(), 'Iba_Store_Sap_Simulation', '');
     ibalogs.add(priceLog);    
    throw e;
}finally {
    IBA_store_datatableHelper.createIbaStoreLog(ibalogs);
}
 
Abdul KhatriAbdul Khatri
Hi boliset,

I do not see DML Insert statement anywhere in the code. Here I added
 
List<IBA_Store_Log__c> ibaLogs = New List<IBA_Store_Log__c>(); 
try
{
	integer x = 1/0;
} 
catch (exception e) 
{
	IBA_Store_Log__c priceLog = IBA_store_datatableHelper.createIbaLog('ERROR', e.getmessage() + e.getlinenumber(), 'Iba_Store_Sap_Simulation', '');
    ibalogs.add(priceLog); 
    Insert ibalogs;
    
    throw e;
}
finally
{
    IBA_store_datatableHelper.createIbaStoreLog(ibalogs);
}

 
boliset kumarboliset kumar
Hello its in my datahelper class IBA_store_datatableHelper.createIbaStoreLog(ibalogs);
paul diracpaul dirac
Hey, just move the 'createIbaStoreLog' call in the catch statement
Abdul KhatriAbdul Khatri
Can you share the code what you have in createIbaLog?