Skip to content

Saves Apex exceptions in database for further analysis using reports or sending out workflow email alerts!

Notifications You must be signed in to change notification settings

sjurgis/salesforce-exception-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

salesforce-exception-logger Deploy to Salesforce

Log your exceptions for further analysis using reports or sending out workflow email alerts!

Invoke using ExLog.add(<Trigger || Class>, Object name, Method Name, exception object, is future) in the catch block of functions.

For example: ExLog.add('Trigger', 'Account', 'SomeFunction', e, false);

Use in Visualforce:

<apex:page standardcontroller="Lead" extensions="LeadExtension">
<button onclick="javascript:causeException();" > log exception </button>
  <script>
   function causeException(){
     try {
       invalidFunctionName('foo');
     } catch (e) {
        Visualforce.remoting.timeout = 120000; // Set timeout at page level
        Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.LeadExtension.logException}',
            e.message, 
            e.stack, 
            handleResult,
            {escape:true}
        );
        function handleResult(result, event) { 
          throw e;
        }
     }
   }
  </script>
</apex:page>
public class LeadExtension {
  @RemoteAction public static void logException (string message, string stack) {
    ExLog.ObjectWritter(
      JSON.serialize (
        new Exception_log__c (
            Message__c = message
          , Stack_Trace__c = stack
          , Source_Type__c = 'Visualforce'
          , Object_Name__c = 'N/A'
          , Method_name__c = 'causeException'
          , Exception_Type__c = 'JavaScript exception'
        )
      )
    );
  }
}

About

Saves Apex exceptions in database for further analysis using reports or sending out workflow email alerts!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages