Created
July 13, 2015 20:48
-
-
Save bahmutov/7e7fe81999463391c662 to your computer and use it in GitHub Desktop.
How to detect invalid IndexedDB (in Firefox incognito mode for example) when opening PouchDB?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I am trying to open PouchDB normally, but this fails in Firefox Incognito mode | |
var db = new PouchDB('test'); | |
// InvalidStateError | |
// I see the idb error callback being called if the open request fails | |
exports.idbError = function (callback) { | |
return function (event) { | |
var message = (event.target && event.target.error && | |
event.target.error.name) || event.target; | |
callback(errors.error(errors.IDB_ERROR, message, event.type)); | |
}; | |
}; | |
// I want to catch this error and maybe switch to using memory provider, but do not see | |
// a way to attach error handler to the PouchDB function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment