ErrorUtils: improved logging and localizedDescription to include underlying errors#1974
Merged
Conversation
…Convertible` This allows methods throwing something like `BackendError` and converting it to `PurchasesError` automatically.
…underlying errors - `Error.localizedDescription` now matches the message being logged The following errors are improved: - Before: > 😿‼️ There was an unknown backend error. - After: > 😿‼️ There was an unknown backend error. Page not found - 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 - Before: > ["$email": "invalid"] - After: > One or more of the attributes sent could not be saved. ["$email": "invalid"]
55caf13 to
1c5e64f
Compare
tonidero
approved these changes
Oct 11, 2022
NachoSoto
added a commit
that referenced
this pull request
Oct 11, 2022
Finishes [CSDK-451].
This new small public API allows users to quickly figure out if everything in the SDK is correctly configured in a simple way:
```swift
let tester = SDKTester.default
do {
try await tester.test()
} catch {
print(error)
}
```
The specific underlying errors will provide information about what failed.
We can continue growing this to check for more specific things, but for now it does 4 things:
- Verify API connectivity: networking issues, firewalling, etc.
- Verify API key is correct
- Verify `Offerings` are configured correctly
- Verify that all products in `Offerings` are configured correctly and found in `StoreKit`
This new API is covered by:
- API testers
- Unit tests
- Integration tests (both on `SK1` and `SK2`)
- #1970
- #1971
- #1973
- #1974
- #1975
- #1976
NachoSoto
added a commit
that referenced
this pull request
Oct 14, 2022
Finishes [CSDK-451].
This new small public API allows users to quickly figure out if everything in the SDK is correctly configured in a simple way:
```swift
let tester = SDKTester.default
do {
try await tester.test()
} catch {
print(error)
}
```
The specific underlying errors will provide information about what failed.
We can continue growing this to check for more specific things, but for now it does 4 things:
- Verify API connectivity: networking issues, firewalling, etc.
- Verify API key is correct
- Verify `Offerings` are configured correctly
- Verify that all products in `Offerings` are configured correctly and found in `StoreKit`
This new API is covered by:
- API testers
- Unit tests
- Integration tests (both on `SK1` and `SK2`)
- #1970
- #1971
- #1973
- #1974
- #1975
- #1976
NachoSoto
added a commit
that referenced
this pull request
Oct 27, 2022
Finishes [CSDK-451].
This new small public API allows users to quickly figure out if everything in the SDK is correctly configured in a simple way:
```swift
let tester = SDKTester.default
do {
try await tester.test()
} catch {
print(error)
}
```
The specific underlying errors will provide information about what failed.
We can continue growing this to check for more specific things, but for now it does 4 things:
- Verify API connectivity: networking issues, firewalling, etc.
- Verify API key is correct
- Verify `Offerings` are configured correctly
- Verify that all products in `Offerings` are configured correctly and found in `StoreKit`
This new API is covered by:
- API testers
- Unit tests
- Integration tests (both on `SK1` and `SK2`)
- #1970
- #1971
- #1973
- #1974
- #1975
- #1976
NachoSoto
added a commit
that referenced
this pull request
Oct 27, 2022
…errors (#1977) Finishes [CSDK-451]. This new small public API allows users to quickly figure out if everything in the SDK is correctly configured in a simple way: ```swift let diagnostics = PurchasesDiagnostics.default do { try await diagnostics.testSDKHealth() } catch { print(error) } ``` The specific underlying errors will provide information about what failed. We can continue growing this to check for more specific things, but for now it does 4 things: - Verify API connectivity: networking issues, firewalling, etc. - Verify API key is correct - Verify `Offerings` are configured correctly - Verify that all products in `Offerings` are configured correctly and found in `StoreKit` This new API is covered by: - API testers - Unit tests - Integration tests (both on `SK1` and `SK2`) _I've taken the "shortcut" of making this `async` only (while still compatible with Objective-C), which means it's not compatible with iOS 12.x. But that made the implementation a lot simpler, which I think is a useful tradeoff._ ### Depends on: - #1970 - #1971 - #1973 - #1974 - #1975 - #1976 [CSDK-451]: https://revenuecats.atlassian.net/browse/CSDK-451?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
This was referenced Jul 19, 2023
NachoSoto
added a commit
that referenced
this pull request
Jul 23, 2023
… description This has been improved significantly (like #1974). I wrote these tests to see if I could reproduce why the logs in RevenueCat/purchases-flutter#766 don't include the underlying error. It's likely that's using an old version of the SDK, but these tests are still useful.
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.
Changes:
Error.localizedDescriptionnow matches the message being logged. Improvements introduced in Error logging:logErrorIfNeededno longer prints message if it's the same as the error description #1776, for example, now apply to the description too.BackendErrormessages now include underlying error.Examples:
The following errors are improved:
BackendError:API key error:
Attribute errors: