Error logging: logErrorIfNeeded no longer prints message if it's the same as the error description#1776
Merged
Merged
Conversation
NachoSoto
commented
Jul 27, 2022
…e same as the error description Working on [SDKONCALL-62] I realized that there are many instances where we end up logging the same message twice. This PR not only improves the logic, but adds much needed test coverage to `ErrorUtils.logErrorIfNeeded` and error logging in general.
8bf0e45 to
5582a89
Compare
tonidero
approved these changes
Jul 28, 2022
tonidero
left a comment
Contributor
There was a problem hiding this comment.
A few questions but LGTM!
This was referenced Jul 29, 2022
Merged
NachoSoto
added a commit
that referenced
this pull request
Aug 1, 2022
### Fixes: * `CustomerInfoResponseHandler`: return `CustomerInfo` instead of error if the response was successful (#1778) via NachoSoto (@NachoSoto) * Error logging: `logErrorIfNeeded` no longer prints message if it's the same as the error description (#1776) via NachoSoto (@NachoSoto) * fix another broken link in docC docs (#1777) via aboedo (@aboedo) * fix links to restorePurchase (#1775) via aboedo (@aboedo) * fix getProducts docs broken link (#1772) via aboedo (@aboedo) ### Improvements: * `Logger`: wrap `message` in `@autoclosure` to avoid creating when `LogLevel` is disabled (#1781) via NachoSoto (@NachoSoto) ### Other changes: * Lint: fixed `SubscriberAttributesManager` (#1774) via NachoSoto (@NachoSoto)
NachoSoto
added a commit
that referenced
this pull request
Aug 17, 2022
Follow up to #1776. That PR added a lot of tests to cover error logging, and #1778 introduced a small error that wasn't covered: if attribute errors are empty, the `localizedDescription` could end up becoming `"[:]"`. This fixes that. ## Examples: This was the underlying error returned (the output of `error.localizedDescription`): #### Before: > [:] #### After: > There was a credentials issue. Check the underlying error for more details. And this is what was logged (notice that I also fixed `ErrorCode.invalidCredentialsError` to not log as an "Apple Error"): #### Before: > 🍎‼️ There was a credentials issue. Check the underlying error for more details. [:] #### After: > 😿‼️ There was a credentials issue. Check the underlying error for more details.
NachoSoto
added a commit
that referenced
this pull request
Aug 17, 2022
Follow up to #1776. That PR added a lot of tests to cover error logging, and #1778 introduced a small error that wasn't covered: if attribute errors are empty, the `localizedDescription` could end up becoming `"[:]"`. This fixes that. ## Examples: This was the underlying error returned (the output of `error.localizedDescription`): #### Before: > [:] #### After: > There was a credentials issue. Check the underlying error for more details. And this is what was logged (notice that I also fixed `ErrorCode.invalidCredentialsError` to not log as an "Apple Error"): #### Before: > 🍎‼️ There was a credentials issue. Check the underlying error for more details. [:] #### After: > 😿‼️ There was a credentials issue. Check the underlying error for more details.
NachoSoto
added a commit
that referenced
this pull request
Oct 11, 2022
…underlying errors (#1974) ## Changes: - `Error.localizedDescription` now matches the message being logged. Improvements introduced in #1776, for example, now apply to the description too. - Logged `BackendError` messages now include underlying error. ## Examples: The following errors are improved: ### `BackendError`: - Before: > 😿‼️ There was an unknown backend error. - After: > 😿‼️ There was an unknown backend error. Page not found ### API key error: - Before: > 😿‼️ There was a credentials issue. Check the underlying error for more details. - After: > 😿‼️ There was a credentials issue. Check the underlying error for more details. Invalid API key ### Attribute errors: - Before: > ["$email": "invalid"] - After: > One or more of the attributes sent could not be saved. ["$email": "invalid"]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Working on SDKONCALL-62 I realized that there are many instances where we end up logging the same message twice.
This PR not only improves the logic, but adds much needed test coverage to
ErrorUtils.logErrorIfNeededand error logging in general.