Skip to content

Instantly share code, notes, and snippets.

@bahmutov
Created July 13, 2015 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bahmutov/7e7fe81999463391c662 to your computer and use it in GitHub Desktop.
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?
// 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