chrisben/imgcache.js — pull request #9 by BradRubenstein (2013-05-18 03:48:11+00:00)
Title: Add error callbacks for xhr failures on image download.

Greetings - I wanted to share with you a minor fix I made, in case you want to pull it.

On chrome, ImgCache.cacheFile was failing without calling the fail_callback if xhr failed.
So in chrome FileTransferWrapper, I added code to call the given error_callback when the xhr download fails.

It's not perfect, because on PhoneGap, the error parameter is a FileTransferError, while on chrome, it is a FileError if the write fails, and an object configured like a FileTransferError (with a code of 0) if the xhr fails. For my purposes (and I hope for general use), it helps to call the error callback in any case, so the caller can deal with the failure.

(To do: cast the Chrome FileWriter FileError into a FileTransferError, so ImgCache.cacheFile on Chrome returns the same type of error as on PhoneGap.)