Read more here:
Fix private browsing issue
Add curly brace (fix typo)
Nice but feels like this generalizes a bit to much.
How about calling options.error with the error when that error is caught?
Also, would you mind minifying it? I left instructions on how to do so here: http://documentup.com/jeromegn/backbone.localstorage#contributing
Ideally, you'd create a test for this, basically stubbing localStorage with something that throws the error (temporarily) and test if it's caught and sent back the right way. I can see how this might be a bit much though ;)
What's wrong with the solution proposed here: marcuswestin/store.js#42 (comment)?
I think the author's comments there apply in this case as well. It should not be the library's responsibility to detect this issue. Your fix hides the actual issue (localStorage isn't available) and so instead it appears as though it's just a regular error.
That was just a quick fix that we can improve for sure.
@jeromegn Yes, calling option.error passing the actual error is better. I'll try to complete this pull request when I have time.
@gsmaverick Correct me if I'm wrong but the original Backbone.sync implementation will call options.error whenever a model failed to save on the server. I think this pretty much emulates this kind of behavior.
Pass the caught error to options.error
@jeromegn I'm not sure how to write a test which would cover this edge case.
Are we letting this go? Is this still an issue in more recent browser versions?
Here's how a test would work: override window.localStorage temporarily to return the same value a browser in private browsing mode would return.
Fixes #44: Now catching private browsing and sending and error to the…
… error callback. Added a test with localStorage stubbing for this to work.
@jeromegn thanks a lot! Now I see how I should have done this, sorry.