From b234ca89da2399e2ce40594ec0bba076a2ba32a9 Mon Sep 17 00:00:00 2001 From: Jheel Agrawal Date: Fri, 30 Apr 2021 11:29:33 +0530 Subject: [PATCH] Added global visibility and Added logic not to send frames and stacktrace if it is empty --- force-app/main/default/classes/Sentry.cls | 11 +- force-app/main/default/classes/SentryTest.cls | 6 +- .../main/default/classes/Sentry_ApiMock.cls | 19 ++- .../main/default/classes/Sentry_Client.cls | 19 ++- .../main/default/classes/Sentry_Config.cls | 36 +++-- .../main/default/classes/Sentry_Context.cls | 40 +++-- force-app/main/default/classes/Sentry_Dsn.cls | 31 ++-- .../default/classes/Sentry_Environment.cls | 26 +++- .../default/classes/Sentry_Error_Handler.cls | 22 ++- .../main/default/classes/Sentry_Event.cls | 140 +++++++++++------- .../classes/Sentry_ExceptionFactoryTest.cls | 16 +- force-app/main/default/classes/Sentry_Log.cls | 24 ++- .../default/classes/Sentry_LogMessage.cls | 14 +- .../main/default/classes/Sentry_LogTest.cls | 15 +- .../classes/Sentry_TestingController.cls | 11 +- .../classes/Sentry_TestingMiddleware.cls | 19 ++- .../default/classes/Sentry_TestingThrower.cls | 19 ++- 17 files changed, 316 insertions(+), 152 deletions(-) diff --git a/force-app/main/default/classes/Sentry.cls b/force-app/main/default/classes/Sentry.cls index cfa2186..eae23e9 100644 --- a/force-app/main/default/classes/Sentry.cls +++ b/force-app/main/default/classes/Sentry.cls @@ -2,20 +2,23 @@ * @description : * @author : jmather * @group : - * @last modified on : 04-28-2021 + * @last modified on : 04-29-2021 * @last modified by : Jheel * Modifications Log * Ver Date Author Modification * 1.0 08-10-2019 jmather Initial Version * 1.1 04-28-2021 Jheel Added a method to send custom title and breadcrumbs to Sentry + * 1.2 04-29-2021 Jheel Added global visibility for the class and required methods **/ -public without sharing class Sentry { - public static void record(Exception e) { +global without sharing class Sentry +{ + global static void record(Exception e) + { Sentry_Event err = convertExceptionToError(e); sendEvent(err); } - public static void record(String issueTitle, Exception e, List lExtraMessages) + global static void record(String issueTitle, Exception e, List lExtraMessages) { Sentry_Event err = convertExceptionToError(issueTitle, e, lExtraMessages); sendEvent(err); diff --git a/force-app/main/default/classes/SentryTest.cls b/force-app/main/default/classes/SentryTest.cls index e81c9dd..84b50a7 100644 --- a/force-app/main/default/classes/SentryTest.cls +++ b/force-app/main/default/classes/SentryTest.cls @@ -2,15 +2,17 @@ * @description : * @author : jmather * @group : - * @last modified on : 04-28-2021 + * @last modified on : 04-29-2021 * @last modified by : Jheel * Modifications Log * Ver Date Author Modification * 1.0 08-10-2019 jmather Initial Version * 1.1 04-28-2021 Jheel Added new methods RecordwithCustomException() and RecordCustomExceptionWithoutSendingToSentry() for test class coverge + * 1.2 04-29-2021 Jheel Added global visibility for the class and required methods **/ @IsTest -public with sharing class SentryTest { +global with sharing class SentryTest +{ @IsTest static void Record() { Exception ex; diff --git a/force-app/main/default/classes/Sentry_ApiMock.cls b/force-app/main/default/classes/Sentry_ApiMock.cls index 9185305..6281ad4 100644 --- a/force-app/main/default/classes/Sentry_ApiMock.cls +++ b/force-app/main/default/classes/Sentry_ApiMock.cls @@ -1,10 +1,19 @@ /** - * Created by jmather on 2019-08-10. - */ - + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ @IsTest -public with sharing class Sentry_ApiMock implements HttpCalloutMock { - public HttpResponse respond(HttpRequest param1) { +global with sharing class Sentry_ApiMock implements HttpCalloutMock +{ + global HttpResponse respond(HttpRequest param1) + { System.debug(param1); HttpResponse response = new HttpResponse(); response.setStatusCode(200); diff --git a/force-app/main/default/classes/Sentry_Client.cls b/force-app/main/default/classes/Sentry_Client.cls index e73d673..12af495 100644 --- a/force-app/main/default/classes/Sentry_Client.cls +++ b/force-app/main/default/classes/Sentry_Client.cls @@ -1,11 +1,20 @@ /** - * Created by Jacob Mather on 2019-03-18. - */ - -public with sharing class Sentry_Client { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global with sharing class Sentry_Client +{ private static Sentry_Dsn dsn = Sentry_Config.getDsn(); - public static void sendEventToSentry(String serializedEvent) { + global static void sendEventToSentry(String serializedEvent) + { HttpRequest req = new HttpRequest(); // you'll have to register a remote site for this url, but can probably just do a generic https://sentry.io... diff --git a/force-app/main/default/classes/Sentry_Config.cls b/force-app/main/default/classes/Sentry_Config.cls index f564db0..f68f3c4 100644 --- a/force-app/main/default/classes/Sentry_Config.cls +++ b/force-app/main/default/classes/Sentry_Config.cls @@ -1,13 +1,22 @@ /** - * Created by Jacob Mather on 2019-06-25. - */ - -public without sharing class Sentry_Config { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global without sharing class Sentry_Config +{ private static Boolean isInDebugMode = null; private static Sentry_Active_Config__c activeConfig; private static Sentry_Config__mdt config; - public static Sentry_Config__mdt getConfig() { + global static Sentry_Config__mdt getConfig() + { checkDebugging(); if (config == null) { @@ -41,7 +50,8 @@ public without sharing class Sentry_Config { return config; } - public static String getEnvironmentName() { + global static String getEnvironmentName() + { Sentry_Active_Config__c ac = getActiveConfig(); if (String.isBlank(ac.Environment_Name__c)) { @@ -51,11 +61,13 @@ public without sharing class Sentry_Config { return ac.Environment_Name__c; } - public static Sentry_Dsn getDsn() { + global static Sentry_Dsn getDsn() + { return new Sentry_Dsn(getConfig().DSN__c); } - public static Boolean checkDebugging() { + global static Boolean checkDebugging() + { if (isInDebugMode == null) { Sentry_Active_Config__c ac = getActiveConfig(); @@ -71,7 +83,8 @@ public without sharing class Sentry_Config { return isInDebugMode; } - public static Boolean canSendToSentry() { + global static Boolean canSendToSentry() + { Sentry_Active_Config__c ac = getActiveConfig(); Sentry_Log.logSentry('[Sentry_config.canSendToSentry] active config: ' + JSON.serializePretty(ac)); @@ -83,7 +96,8 @@ public without sharing class Sentry_Config { return ac.IsIssueCreationDisabled__c == false; } - private static Sentry_Active_Config__c getActiveConfig() { + private static Sentry_Active_Config__c getActiveConfig() + { if (activeConfig == null) { activeConfig = Sentry_Active_Config__c.getOrgDefaults(); } @@ -91,5 +105,5 @@ public without sharing class Sentry_Config { return activeConfig; } - public class SentryConfigException extends Exception {} + global class SentryConfigException extends Exception {} } \ No newline at end of file diff --git a/force-app/main/default/classes/Sentry_Context.cls b/force-app/main/default/classes/Sentry_Context.cls index 7145145..588019f 100644 --- a/force-app/main/default/classes/Sentry_Context.cls +++ b/force-app/main/default/classes/Sentry_Context.cls @@ -1,23 +1,35 @@ /** - * Created by Jacob Mather on 2019-03-25. - */ - -public abstract class Sentry_Context { - public static Map create() { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global abstract class Sentry_Context +{ + global static Map create() + { return new Map(); } - public static Map Basic() { + global static Map Basic() + { return new Map(); } - public static Map Breadcrumbs() { + global static Map Breadcrumbs() + { Map data = create(); data.put('values', create()); return data; } - public static Map OsSystem() { + global static Map OsSystem() + { return new Map { 'os' => Server(), 'runtime' => Runtime(), @@ -25,28 +37,32 @@ public abstract class Sentry_Context { }; } - public static Map Org() { + global static Map Org() + { return new Map { 'name' => Sentry_Environment.getInstanceLabel(), 'type' => String.valueOf(Sentry_Environment.getInstanceType()) }; } - public static Map Server() { + global static Map Server() + { return new Map { 'name' => 'Salesforce', 'version' => '1' }; } - public static Map Runtime() { + global static Map Runtime() + { return new Map { 'name' => 'Apex', 'version' => '1' }; } - public static Map User() { + global static Map User() + { return new Map { 'id' => UserInfo.getUserId(), 'username' => UserInfo.getUserName(), diff --git a/force-app/main/default/classes/Sentry_Dsn.cls b/force-app/main/default/classes/Sentry_Dsn.cls index 2f77924..47bc260 100644 --- a/force-app/main/default/classes/Sentry_Dsn.cls +++ b/force-app/main/default/classes/Sentry_Dsn.cls @@ -1,15 +1,24 @@ /** - * Created by Jacob Mather on 2019-03-25. - */ - -public with sharing class Sentry_Dsn { - public String privateKey; - public String publicKey; - public String projectId; - public Url sentryUrl; - public Url url; - - public Sentry_Dsn(String dsn) { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global with sharing class Sentry_Dsn +{ + global String privateKey; + global String publicKey; + global String projectId; + global Url sentryUrl; + global Url url; + + global Sentry_Dsn(String dsn) + { url = new Url(dsn); this.publicKey = getPublicKey(url); this.privateKey = getPrivateKey(url); diff --git a/force-app/main/default/classes/Sentry_Environment.cls b/force-app/main/default/classes/Sentry_Environment.cls index 3944444..2dfcd71 100644 --- a/force-app/main/default/classes/Sentry_Environment.cls +++ b/force-app/main/default/classes/Sentry_Environment.cls @@ -1,11 +1,20 @@ /** - * Created by Jacob Mather on 2019-06-25. - */ - -public without sharing class Sentry_Environment { - public enum InstanceType { PRODUCTION, TRIAL, SANDBOX, SCRATCH_ORG } - - public static String getInstanceLabel() { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global without sharing class Sentry_Environment +{ + global enum InstanceType { PRODUCTION, TRIAL, SANDBOX, SCRATCH_ORG } + + global static String getInstanceLabel() + { String orgUrl = Url.getOrgDomainUrl().toExternalForm(); Sentry_Log.logSentry('[Sentry_Environment.getInstanceLabel] orgUrl: ' + orgUrl); List protoAndRemainder = orgUrl.split('://'); @@ -27,7 +36,8 @@ public without sharing class Sentry_Environment { return url_fragment.split('--')[0].toLowerCase(); } - public static InstanceType getInstanceType() { + global static InstanceType getInstanceType() + { Organization org = [SELECT InstanceName, IsSandbox, TrialExpirationDate FROM Organization]; if (org.IsSandbox == true && org.TrialExpirationDate == null) { diff --git a/force-app/main/default/classes/Sentry_Error_Handler.cls b/force-app/main/default/classes/Sentry_Error_Handler.cls index 4ed0edb..14b5060 100644 --- a/force-app/main/default/classes/Sentry_Error_Handler.cls +++ b/force-app/main/default/classes/Sentry_Error_Handler.cls @@ -1,9 +1,18 @@ /** - * Created by Jacob Mather on 2019-06-25. - */ - -public with sharing class Sentry_Error_Handler { - public void run() { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global with sharing class Sentry_Error_Handler +{ + global void run() + { List errors = new List(); for (Sentry_Error__e e : (List) Trigger.new) { @@ -29,7 +38,8 @@ public with sharing class Sentry_Error_Handler { } @Future(Callout=true) - public static void sendErrors(List errors) { + global static void sendErrors(List errors) + { for (String error : errors) { Sentry_Client.sendEventToSentry(error); } diff --git a/force-app/main/default/classes/Sentry_Event.cls b/force-app/main/default/classes/Sentry_Event.cls index 08537df..18c2af4 100644 --- a/force-app/main/default/classes/Sentry_Event.cls +++ b/force-app/main/default/classes/Sentry_Event.cls @@ -2,76 +2,83 @@ * @description : * @author : jmather * @group : - * @last modified on : 04-28-2021 + * @last modified on : 04-29-2021 * @last modified by : Jheel * Modifications Log * Ver Date Author Modification * 1.0 08-10-2019 jmather Initial Version * 1.1 04-28-2021 Jheel Added logic to send proper detailed data to Sentry with Breadcrumbs as well + * 1.2 04-29-2021 Jheel Added global visibility for the class and required methods + * 1.3 04-29-2021 Jheel Added logic not to send frames and stacktrace if it is empty and added logic to cover managed package stacktrace **/ -public without sharing class Sentry_Event { +global without sharing class Sentry_Event +{ // uuid - public String event_id; + global String event_id; - public String timestamp; + global String timestamp; - public String level = 'error'; + global String level = 'error'; - public String platform = 'salesforce'; + global String platform = 'salesforce'; - public Map sdk = new Map { 'name' => 'sentry.apex', 'version' => '1' }; + global Map sdk = new Map { 'name' => 'sentry.apex', 'version' => '1' }; - public String logger; + global String logger; - public String server_name; + global String server_name; - public String release; + global String release; - public String message; + global String message; - public String environment; + global String environment; - public String[] modules; + global String[] modules; - public Map request = Sentry_Context.Basic(); + global Map request = Sentry_Context.Basic(); - public Map extra = Sentry_Context.Basic(); + global Map extra = Sentry_Context.Basic(); - public Map user = Sentry_Context.User(); + global Map user = Sentry_Context.User(); - public Map contexts = Sentry_Context.OsSystem(); + global Map contexts = Sentry_Context.OsSystem(); - public Map tags = Sentry_Context.Basic(); + global Map tags = Sentry_Context.Basic(); - public String[] fingerprint; + global String[] fingerprint; - public Map breadcrumbs = Sentry_Context.Breadcrumbs(); + global Map breadcrumbs = Sentry_Context.Breadcrumbs(); - public Map exceptionValues = new Map { 'values' => new List>() }; + global Map exceptionValues = new Map { 'values' => new List>() }; - public Map breadcrumbsValues = new Map { 'values' => new List>() }; + global Map breadcrumbsValues = new Map { 'values' => new List>() }; - public String messageFormatted; + global String messageFormatted; - public String[] messageParams; + global String[] messageParams; - public String stacktrace; + global String stacktrace; - public Sentry_Event() { + global Sentry_Event() + { initialize(); } - public Sentry_Event(Sentry_Exception ex) { + global Sentry_Event(Sentry_Exception ex) + { this((Exception) ex); System.debug('custom' + ex.getCustomStackTraceAsString()); } - public Sentry_Event(Exception ex) { + global Sentry_Event(Exception ex) + { this(null, ex, null); } // Custom Method with custom issueTitle and extra messages - public Sentry_Event(String issueTitle, Exception ex, List lExtraMessages) { + global Sentry_Event(String issueTitle, Exception ex, List lExtraMessages) + { initialize(); Sentry_Log.logSentry('Got exception: ' + ex); @@ -109,18 +116,18 @@ public without sharing class Sentry_Event { { System.debug('@@m:--'+m); frames.add(new Map { - 'class' => m.group(1), - 'filename' => m.group(1) + '.cls', - 'function' => m.group(1) + '.' + m.group(2) + ', line ' + m.group(3), - 'lineno' => Integer.valueOf(m.group(3)), - 'column' => Integer.valueOf(m.group(4)), - 'in_app'=> true, - 'vars' => new Map { - 'column' => m.group(4), - 'line' => Integer.valueOf(m.group(3)), - 'class'=> m.group(1), - 'function' => m.group(2) - } + 'class' => m.group(1), + 'filename' => m.group(1) + '.cls', + 'function' => m.group(1) + '.' + m.group(2) + ', line ' + m.group(3), + 'lineno' => Integer.valueOf(m.group(3)), + 'column' => Integer.valueOf(m.group(4)), + 'in_app'=> true, + 'vars' => new Map { + 'column' => m.group(4), + 'line' => Integer.valueOf(m.group(3)), + 'class'=> m.group(1), + 'function' => m.group(2) + } }); } else @@ -132,24 +139,46 @@ public without sharing class Sentry_Event { { System.debug('@@m:--'+m); frames.add(new Map { - 'class' => m.group(1), - 'filename' => m.group(1) + '.cls', - 'function' => m.group(1) /*+ '.' + m.group(2) */+ ', line ' + m.group(2), - 'lineno' => Integer.valueOf(m.group(2)), - 'column' => Integer.valueOf(m.group(3)), - 'in_app'=> true, - 'vars' => new Map { - 'column' => m.group(3), - 'line' => Integer.valueOf(m.group(2)), - 'class'=> m.group(1) - } + 'class' => m.group(1), + 'filename' => m.group(1) + '.cls', + 'function' => m.group(1) /*+ '.' + m.group(2) */+ ', line ' + m.group(2), + 'lineno' => Integer.valueOf(m.group(2)), + 'column' => Integer.valueOf(m.group(3)), + 'in_app'=> true, + 'vars' => new Map { + 'column' => m.group(3), + 'line' => Integer.valueOf(m.group(2)), + 'class'=> m.group(1) + } + }); + } + // For Managed Package Exceptions. Sample: (Sentry) + else + { + frames.add(new Map { + 'function' => line, + 'in_app'=> true, + 'vars' => new Map { + 'class'=> line + } }); } } } - exceptionDataStack.put('frames', frames); - exceptionData.put('stacktrace', exceptionDataStack); + if(!frames.isEmpty()) + { + exceptionDataStack.put('frames', frames); + exceptionData.put('stacktrace', exceptionDataStack); + } + else + { + if(lExtraMessages == null) + { + lExtraMessages = new List(); + } + lExtraMessages.add(new Sentry_LogMessage(PCH.Sentry_LogMessage.LEVEL_ERROR, ex.getMessage()+'\nStacktrace:-'+ex.getStackTraceString())); + } // add "value" in exceptionData exceptionData.put('value', ex.getTypeName()+' '+ex.getMessage()); @@ -197,7 +226,8 @@ public without sharing class Sentry_Event { environment = Sentry_Config.getEnvironmentName(); } - public Map toMessage() { + global Map toMessage() + { Map msg = Sentry_Context.create(); msg.put('event_id', event_id); msg.put('environment', environment); diff --git a/force-app/main/default/classes/Sentry_ExceptionFactoryTest.cls b/force-app/main/default/classes/Sentry_ExceptionFactoryTest.cls index bb218b7..6c4c059 100644 --- a/force-app/main/default/classes/Sentry_ExceptionFactoryTest.cls +++ b/force-app/main/default/classes/Sentry_ExceptionFactoryTest.cls @@ -1,9 +1,17 @@ /** - * Created by jmather on 2019-08-12. - */ - + * @description : + * @author : jmather + * @group : + * @last modified on : 04-30-2021 + * @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ @IsTest -public with sharing class Sentry_ExceptionFactoryTest { +global with sharing class Sentry_ExceptionFactoryTest +{ class BasicException extends Exception {} class ExtendedException extends Sentry_Exception {} diff --git a/force-app/main/default/classes/Sentry_Log.cls b/force-app/main/default/classes/Sentry_Log.cls index 197cbcb..1faf8bb 100644 --- a/force-app/main/default/classes/Sentry_Log.cls +++ b/force-app/main/default/classes/Sentry_Log.cls @@ -1,10 +1,19 @@ /** - * Created by jmather on 2019-08-08. - */ - -global virtual with sharing class Sentry_Log { - public static Boolean debugSentry = false; - public static List logLevels = new List { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global virtual with sharing class Sentry_Log +{ + global static Boolean debugSentry = false; + global static List logLevels = new List + { Sentry_LogMessage.LEVEL_TRACE, Sentry_LogMessage.LEVEL_DEBUG, Sentry_LogMessage.LEVEL_INFO, @@ -97,7 +106,8 @@ global virtual with sharing class Sentry_Log { logError(e.getMessage(), data); } - public static void showDebug(Sentry_LogMessage message) { + global static void showDebug(Sentry_LogMessage message) + { System.debug(message.message); if (message.data.isEmpty()) { diff --git a/force-app/main/default/classes/Sentry_LogMessage.cls b/force-app/main/default/classes/Sentry_LogMessage.cls index a24e3c1..9989d64 100644 --- a/force-app/main/default/classes/Sentry_LogMessage.cls +++ b/force-app/main/default/classes/Sentry_LogMessage.cls @@ -2,20 +2,22 @@ * @description : * @author : jmather * @group : - * @last modified on : 04-28-2021 + * @last modified on : 04-29-2021 * @last modified by : Jheel * Modifications Log * Ver Date Author Modification * 1.0 08-10-2019 jmather Initial Version * 1.1 04-28-2021 Jheel Added few more variables to store other data as well + * 1.2 04-29-2021 Jheel Added global visibility for the class and required methods **/ -global with sharing class Sentry_LogMessage { +global with sharing class Sentry_LogMessage +{ global static final String LEVEL_ERROR = 'error'; global static final String LEVEL_WARN = 'warn'; global static final String LEVEL_INFO = 'info'; global static final String LEVEL_DEBUG = 'debug'; global static final String LEVEL_TRACE = 'trace'; - public static final String LEVEL_SENTRY_DEBUG = 'sys-debug'; + global static final String LEVEL_SENTRY_DEBUG = 'sys-debug'; global String level { get; set; } { level = LEVEL_INFO; } global String type { get; set; } { type = LEVEL_DEBUG; } @@ -24,7 +26,8 @@ global with sharing class Sentry_LogMessage { global Datetime ts { get; private set; } { ts = Datetime.now(); } global Map data { get; set; } { data = new Map(); } - global Sentry_LogMessage(String level, String message) { + global Sentry_LogMessage(String level, String message) + { this.level = (level == LEVEL_ERROR) ? LEVEL_ERROR : LEVEL_INFO; this.message = message; } @@ -37,7 +40,8 @@ global with sharing class Sentry_LogMessage { this.message = message; } - global Sentry_LogMessage(String level, String message, Map logData) { + global Sentry_LogMessage(String level, String message, Map logData) + { this(level, message); this.data = logData; } diff --git a/force-app/main/default/classes/Sentry_LogTest.cls b/force-app/main/default/classes/Sentry_LogTest.cls index 13cfe2c..0570f4a 100644 --- a/force-app/main/default/classes/Sentry_LogTest.cls +++ b/force-app/main/default/classes/Sentry_LogTest.cls @@ -1,8 +1,17 @@ /** - * Created by jmather on 2019-08-12. - */ + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ @IsTest -public with sharing class Sentry_LogTest { +global with sharing class Sentry_LogTest +{ @IsTest static void TestLogging() { Map context = new Map { 'foo' => 'bar' }; diff --git a/force-app/main/default/classes/Sentry_TestingController.cls b/force-app/main/default/classes/Sentry_TestingController.cls index 7b1ea0c..0b91c17 100644 --- a/force-app/main/default/classes/Sentry_TestingController.cls +++ b/force-app/main/default/classes/Sentry_TestingController.cls @@ -2,15 +2,18 @@ * @description : * @author : jmather * @group : - * @last modified on : 04-28-2021 + * @last modified on : 04-29-2021 * @last modified by : Jheel * Modifications Log * Ver Date Author Modification * 1.0 08-10-2019 jmather Initial Version * 1.1 04-28-2021 Jheel Added logic to trigger Custom Exception + * 1.2 04-29-2021 Jheel Added global visibility for the class and required methods **/ -public with sharing class Sentry_TestingController { - public PageReference triggerCapturedException() { +global with sharing class Sentry_TestingController +{ + global PageReference triggerCapturedException() + { try { Sentry_TestingMiddleware.doThing(); } catch (Sentry_Exception e) { @@ -21,7 +24,7 @@ public with sharing class Sentry_TestingController { return null; } - public PageReference triggerCustomException() + global PageReference triggerCustomException() { List lExtraMessages = new List(); lExtraMessages.add(new Sentry_LogMessage(Sentry_LogMessage.LEVEL_INFO, Sentry_LogMessage.LEVEL_DEBUG, Sentry_LogMessage.LEVEL_DEBUG,'Testing debug 1', new Map())); diff --git a/force-app/main/default/classes/Sentry_TestingMiddleware.cls b/force-app/main/default/classes/Sentry_TestingMiddleware.cls index d71fb42..207eb2d 100644 --- a/force-app/main/default/classes/Sentry_TestingMiddleware.cls +++ b/force-app/main/default/classes/Sentry_TestingMiddleware.cls @@ -1,9 +1,18 @@ /** - * Created by jmather on 2019-08-08. - */ - -public with sharing class Sentry_TestingMiddleware { - public static void doThing() { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global with sharing class Sentry_TestingMiddleware +{ + global static void doThing() + { Sentry_TestingThrower thrower = new Sentry_TestingThrower(); thrower.throwException(); diff --git a/force-app/main/default/classes/Sentry_TestingThrower.cls b/force-app/main/default/classes/Sentry_TestingThrower.cls index f294faf..8ee13c8 100644 --- a/force-app/main/default/classes/Sentry_TestingThrower.cls +++ b/force-app/main/default/classes/Sentry_TestingThrower.cls @@ -1,11 +1,20 @@ /** - * Created by jmather on 2019-08-08. - */ - -public with sharing class Sentry_TestingThrower { + * @description : + * @author : jmather + * @group : + * @last modified on : 04-29-2021 + * @last modified by : Jheel + * Modifications Log + * Ver Date Author Modification + * 1.0 08-10-2019 jmather Initial Version + * 1.1 04-29-2021 Jheel Added global visibility for the class and required methods +**/ +global with sharing class Sentry_TestingThrower +{ class MyException extends Sentry_Exception {} - public void throwException() { + global void throwException() + { MyException ex = (MyException) Sentry_ExceptionFactory.build(MyException.class); ex.setMessage('Something broke.'); throw ex;