-
Notifications
You must be signed in to change notification settings - Fork 17
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
Automatic Error Recovery #45
Conversation
Codecov Report
@@ Coverage Diff @@
## release/2.0.0 #45 +/- ##
=================================================
- Coverage 96.91% 96.27% -0.64%
=================================================
Files 31 33 +2
Lines 1068 1208 +140
=================================================
+ Hits 1035 1163 +128
- Misses 33 45 +12
Continue to review full report at Codecov.
|
BackendServiceHelper.handleResponse(response, completion: completion) | ||
|
||
case .failure(let error): | ||
guard let recoveryStrategy = self?.recoveryStrategy else { return completion(.failure(error)) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the else
on this guard
, do we need to pipe it through BackendServerHelper
so that the completion block gets run on the main thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. We very much do. Will tweak that now.
This is another large feature that I want to get in before 2.0 pre-release if possible. Essentially, this does the following:
Recoverable
, which dictates when an arbitrary operation can be recovered from and re-attempted. Also adds an extension onRecoverable
for easily preparing subsequent attempts.BackendService
(should it be a part of theBackendServiceProtocol
?) for aRequestRecoveryStrategy
. This object allows for certain errors to be handled automatically by returning a specificRecoveryDisposition
ofretry
orfail
.For example: If the error returned is a 401 unauthorized, the recovery strategy can add the appropriate authorization header to the request, and return
retry
.I can look into a subspec if we think that it belongs in one.