Log entire NSError
instead of just localizedDescription
#1068
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Give developers more error details by logging the entire
NSError
instead of just thelocalizedDescription
, which many not exist for the error.Details
Motivation
These changes were brought up when a customer was getting failure for sending receive receipts but the error logged was
(Error 0 in OneSignal Error.)
, not so informative. This is because the error'slocalizedDescription
was being logged when it didn't have that information set. When missing, a default string is constructed from the domain and code.Context
To properly provide
localizedDescription
, we would have to provide a keyNSLocalizedDescriptionKey
in theuserInfo
dictionary. Most of the NSErrors created in the SDK use a key of"error"
instead, and in a few other cases, a key of"returned"
. Only 1 error at the time of this PR usesNSLocalizedDescriptionKey
.The SDK creates and handles errors in a variety of ways, and the scope of this PR is limited to logging.
I also looked at other error logging that used
error.description
and this does give the full error details as well.Example Log
Here is an example of what is logged for
error
orerror.description
:The "(null)" is the localized description.
Scope
Just affects logging only.
Manual testing
Tested what is logged on different errors using the error object itself,
error. localizedDescription
, anderror.description
(which is used in some other instances).Affected code checklist
Checklist
Overview
Testing
Final pass
This change is