If we are using an AVAssetResourceLoaderDelegate, and performing our own playlist requests using a URLSession, what are some best practices for responding to the resource loading requests with errors? In other words, how best to populate the NSError domain, code, and userInfo values when calling finishLoadingWithError?
SImilarly, are there any things to look out for when the URLSession has caching enabled, and we receive HTTP 304s for live playlists? The URLSession appears to transparently handle the 304, and return a 200 with the cached data in the URLSession callbacks. But could there be edge cases where the URLSession’s cache is becoming invalid just as we get a 304?
If the problem that's encountered is well-covered by an existing public error code in a public error domain, such as the NSURLErrorDomain, the best practice is to create an NSError with that code and domain. This will ensure the broadest possible recognition of the source of the problem.
If instead the problem is something peculiar to your implementation, and you have no expectation of end-user recovery or other mitigation, it's certainly possible to employ your own error domain and error code. In any such case, it may also be helpful to populate the NSError user dictionary key NSDebugDescriptionErrorKey.