Handle connection lost
error on the DailyChallengeView
#179
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.
Why the PR:
I tried to play the game in airplane mode and maybe didn't pay much attention where I tapped so I opened the
DailyChallengeView
. When I tapped either one of the two GameButtons nothing happened. I then realised I am offline I guess maybe would have expected some kind of message to tell me that I want to play a mode that expects a successful response from a network to set the state.➕ Added
When the API request fails I try to map the code of the NSError to a
FailureReason
which gets set to theApiError
.From there it gets passed to the state and actually just the
failureReason
of the Error gets pulled out to be exposed to the view components.🧪 Experiment
I wanted to try out the waters I guess and see if this kind of functionality is something you'd consider adding to the codebase. The usage of
String?
to transport the errorMessage might not be ideal and maybe something like theFailureReason
enum is better suited and could also communicate better what errors should be considered as gameblocking.Let me know what you think
👀 Screenshots