INSOperationsKit
INSOperationsKit copied to clipboard
INSURLSessionTaskOperation does not surface errors
Hey everyone!
It seems as though it's currently impossible to surface errors from inside INSURLSessionTaskOperation.
I've tried calling -finishWithError: from inside the completion block of my NSURLSessionTask, but the operation is already completed at that point (due to KVO on the 'state' of the sessionTask).
I think there are two ways we can fix this:
- Change the KVO method to call [self finishWithError:self.task] instead of [self finish] when the URLSessionTask completes. This is a simple fix and shouldn't create any timing issues. OR
- Complete the operation only once the completion block on the NSURLSessionTask has finished running. This would allow the user to surface his own errors instead of the URLSession errors.
What do you all think? Have you experienced the same issue?