Skip to content

Commit

Permalink
feature(examples): add non rollbar example and manual apex notificait…
Browse files Browse the repository at this point in the history
…on sending; ref #5
  • Loading branch information
ArturMoczulski committed Oct 28, 2019
1 parent dd30ace commit d2a9c65
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
26 changes: 26 additions & 0 deletions force-app/main/default/classes/RollbarTestPageController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public with sharing class RollbarTestPageController {
return null;
}

public Pagereference testLogExceptionNoRollbar() {
this.buildData();
return null;
}

public Pagereference testLogException() {
Rollbar.init();
try {
Expand All @@ -27,10 +32,31 @@ public with sharing class RollbarTestPageController {
ex,
custom
);
throw ex;
}
return null;
}

public void sendApexExceptionNotification() {
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.toAddresses = new String[] { 'rollbaremailservice@2my1sei6hsps5lb9mk19i6pcs6rgojf2drlc44ubduzh0ups3b.2e-mc3puaq.na91.apex.salesforce.com' };
message.subject = 'Developer script exception from Rollbar, Inc. : RollbarTestPageController : Attempt to de-reference a null object';
message.plainTextBody = 'Apex script unhandled exception by user/organization: 0052E00000Hy7Kg/00D2E000000mc3P\n' +
'\n' +
'Visualforce Page: /apex/RollbarTestPage\n' +
'\n' +
'\n' +
'\n' +
'caused by: System.NullPointerException: Attempt to de-reference a null object\n'+
'\n' +
'Class.RollbarTestPageController.buildVersionString: line 50, column 1\n'+
'Class.RollbarTestPageController.buildData: line 44, column 1\n'+
'Class.RollbarTestPageController.testLogException: line 26, column 1\n';

Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {message};
Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
}

public Map<String, String> buildData()
{
Map<String, String> structure = new Map<String, String>();
Expand Down
9 changes: 8 additions & 1 deletion force-app/main/default/pages/RollbarTestPage.page
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
}
</code>
<p>Report an exception with a stack trace to Rollbar.</p>
<apex:commandButton action="{!testLogException}" value="Run" />
</apex:pageBlockSection>
<apex:pageBlockSection>
<apex:commandButton action="{!testLogException}" value="Run with Rollbar" />
<apex:commandButton action="{!testLogExceptionNoRollbar}" value="Run without Rollbar" />
</apex:pageBlockSection>
<apex:pageBlockSection title="Report an unhandled Apex exception">
<code>
Expand All @@ -56,7 +59,11 @@
</code>
<p>This example causes an unhandled null pointer exception in Apex code.</p>
<p>The expected behavior is to receive an occurrence in Rollbar including information about the exception.</p>

</apex:pageBlockSection>
<apex:pageBlockSection>
<apex:commandButton action="{!testUnhadledException}" value="Run" />
<apex:commandButton action="{!sendApexExceptionNotification}" value="Send Apex Notification Manually" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
Expand Down

0 comments on commit d2a9c65

Please sign in to comment.