Hi all!
Thanks for really helpful lib!
Can anybody help me?
I have chain of 3 tasks ( request to BE) .
Every task/request can return error with code 401 . But I need to know which task failed , because in case 401 I need to perform different steps depending on which task failed.
Code sample:
let verifyTask = interactor.verifySMSCode(verificationID: verification.codeID, code: smsCode)
verifyTask.continueOnSuccessWithTask { token -> Task<LoginResponse> in
self.interactor.saveSMSToken(token: token)
return self.interactor.login(phone: self.user.phoneNumber)
}.continueOnSuccessWithTask { loginResponse -> Task<UserDetails> in
self.interactor.saveAuthData(authData: loginResponse)
return self.interactor.requestUserDetails(userID: loginResponse.userID)
}.continueOnSuccessWith(Executor.mainThread) { [weak self] userDetails in
self?.view.hideActivityIndicator()
self?.interactor.saveUserDetails(userDetails: userDetails)
self?.moduleOutput.didLoginSuccessfuly()
}.continueOnErrorWith(Executor.mainThread) { [weak self] error in
self?.view.hideActivityIndicator()
if (error as NSError).code == 401 {
// every of 3 requests / task can return me error code == 401
// How can I understand which of previous 3 task failed???
}
self?.view.showError(title: nil, message: error.localizedDescription, buttonTitile: "OK")
}
Are there any ways to separate which task are failed in continueOnErrorWith block ??
P.S. I want to use chain of tasks to make code look better.
I don't wont to use :
verifyTask.continueWith { task in
if let result = task.result {
self.interactor.login(phone: user.phoneNumber).continueWith { task in
self.interactor.requestUserDetails(userID: result.userID).continueWith {
if ///
}
}
} else if let err = task.error {
//
}
}
Hi all!
Thanks for really helpful lib!
Can anybody help me?
I have chain of 3 tasks ( request to BE) .
Every task/request can return error with code 401 . But I need to know which task failed , because in case 401 I need to perform different steps depending on which task failed.
Code sample:
Are there any ways to separate which task are failed in continueOnErrorWith block ??
P.S. I want to use chain of tasks to make code look better.
I don't wont to use :