v4.11.2 - New Logger.exception() methods for Apex developers #537
jongpie
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Core Unlocked Package Changes
New Logger.exception() methods for Apex developers
This release provides some syntactic sugar for Apex developers when logging exceptions. A common pattern for using Nebula Logger is to log exceptions in
try-catch
blocks. Once an exception has been caught, Apex developers have to add 3 lines of code in order to log the exception & re-throw it, as shown below:Although 3 lines of code isn't a huge amount of code, it's still tedious to have to repeat the same code in any relevant
try-catch
blocks. Now, Apex developers can use the new method overloadsLogger.exception()
to consolidate down to 1 line in acatch
block. The end result of the below snippet is identical to the snippet above - both result in a newERROR
log entry being generated, automatically saved, and then the exception is thrown.The full list of new
Logger.exception()
method overloads is shown below. Each of the methods will log an entry withERROR
logging level, save the log, and then throw the provided exception. Since an exception is always thrown, the method overloads all have avoid
return type.Bugfixes
api.status.salesforce.com
would cause exceptions in Nebula Logger if the remote site setting was disabled and the callout was still enabled viaLoggerParameter__mdt
recordCallStatusApi
. Now, Nebula Logger internally catches any callout exceptions, which should prevent any downstream issues from occurring.Apex Test Improvements
TODO
items in the Apex classLogger_Tests
(part of the logger engine layer) so that it's not aware of the log-management layer by rewriting several test methods to remove references toLog__c
andLogEntry__c
. These tests now also use mocks for theSystem.EventBus
class, so they're now much faster 🏎️Pipeline Enhancements
sf
CLI, instead of thesfdx
cli` (PR Solve issue 527 - update scripts to use @salesforce/cli (SF cli) #532). Thanks to @JMercie for another amazing contribution! 🥳Installation Info
Core Unlocked Package - no namespace
Full Changelog: v4.11.1...v4.11.2
sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001TsZAQA0
sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001TsZAQA0
This discussion was created from the release New Logger.exception() methods for Apex developers.
Beta Was this translation helpful? Give feedback.
All reactions