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
sharathchandra thukkanisharathchandra thukkani 

Need to capture the stack trace when Database.Error is Used

Hi
Below is my sample code where i'm inserting the error occured for DML operation into SFDC_Log__c object. Can i capture the Stack Trace by using substring and index concept over here, have any one tried. It will also be helpful if any once can post the exact error message how it looks.

 //log bad Inserts
                    if(!objResult.isSuccess()){
                        Database.Error err =  objResult.getErrors()[0];
                        objSfdcLog = new SFDC_Log__c();
                        objSfdcLog.Error_Message__c = err.getMessage().substring(0,255);
                        objSfdcLog.ToAddress__c = strToAddress;
                        objSfdcLog.FromAddress__c = strFromAddress;
                        lstSFDCLog.add(objSfdcLog);
                        System.Debug('######## Error while inserting Case: '+err.getStatusCode()+' '+err.getMessage());
                    }
sharathchandra thukkanisharathchandra thukkani
I can try this but due to time factor i have posted this..
Deepak Veeravalli 10Deepak Veeravalli 10
Hi SharathChandra, Am alos in the same situation like you. Was wondering if you were able to achieve this.