-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Logger.exception() methods for Apex developers #535
New Logger.exception() methods for Apex developers #535
Conversation
3c4fe2d
to
bc1de52
Compare
…, save, and throw the provided exception
… ApexDocs comments in Logger
…e log-management layer
…returning null when exceptions occur
3e41f51
to
4f16b64
Compare
4f16b64
to
1a6f002
Compare
1a6f002
to
f779b98
Compare
f779b98
to
826cb27
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #535 +/- ##
==========================================
+ Coverage 94.84% 95.96% +1.11%
==========================================
Files 59 47 -12
Lines 6072 4927 -1145
Branches 137 0 -137
==========================================
- Hits 5759 4728 -1031
+ Misses 307 199 -108
+ Partials 6 0 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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.I've also included a bugfix to resolve #529 where the optional integration with
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.