Exceptions Logging

 

Error management (or Exception handling) is an important part of writing good Apex code, and the information contained in errors can be some of the very best content for SightLane monitors.

try{

    ...<your business code>...

} catch (Exception ex){
  System.debug('This is what happened + ex.getMessage());
}

To incorporate SightLane monitors into Apex code dealing with Exceptions, simply update the code this way.  The code below successfully handles both successful and unsuccessful conclusions to your business process.  

sightlane.EventLogger mylogger = sightlane.Logging.startLog('Handle Process Exception');
try{
  mylogger.log('Everything is going smoothly so far!');
  ...<your business code>...
  mylogger.reportToSightLane();  // Report a successful process
} catch (Exception ex){
    mylogger.reportFailureToSightLane(ex);
}
Pro Tip: There is also a mylogger.reportFailureToSightLane() method (note that no exception is provided here).  This purpose of this method is to declare a monitored event to be a logical failure, even when there is no Salesforce Exception.  If your exception handling monitors are not behaving properly, please verify that you have used the right version of reportFailureToSightLane.

In addition to generating a new monitor event, SightLane will capture any Stack Trace produced by the exception and make it available to SightLane users through the Control Center and Event Viewer interfaces, as in the example below.  This means that developers can find out exactly where there was an issue and dive right in to solve it quickly!

errorcode.png

Now your processes are fully monitored, whether they work perfectly or encounter some issues.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.