Haneke / HanekeSwift

A lightweight generic cache for iOS written in Swift with extra love for images.
Apache License 2.0
5.21k stars 591 forks source link

Troubleshooting when success is not success #456

Open eimermusic opened 4 years ago

eimermusic commented 4 years ago

I never see this in my own testing but Sentry crash reports show that some real-world users are getting the following issue. I wonder how I continue to diagnose it.

TL;DR

Fetch (NetworkFetcher) calls the success closure but the data is apparently not ok.

           myCache.fetch(URL: url, failure: {error in
                print("Image fetch error \(String(describing: error)) setting image \(url)")
            }, success: {data in
                print("loaded image: \(url)")
                if let image = UIImage(data: data) {
                    self.scrollView.display(image: image)
                } else {
                    // This is where I want to figure out why data is not actually the image data.
                    // Would it make sense to remove this item from the cache here and have it re-download?
                }
            })

Questions / Ideas