Skip to content

Instantly share code, notes, and snippets.

@paulgosnell
Forked from akgupta/quotaexceeded.js
Created May 3, 2012 08:25
Show Gist options
  • Save paulgosnell/2584347 to your computer and use it in GitHub Desktop.
Save paulgosnell/2584347 to your computer and use it in GitHub Desktop.
handle quota exceeded error in local storage
try {
module.$localStorage[key] = serializer(value);
} catch(e) {
if(e.name === 'QUOTA_EXCEEDED_ERR') {
// reset to make space
module.reset();
module.$localStorage[key] = serializer(value);
} else {
module.localStorageAvailable = false;
$log.error("Local storage write failure - " + e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment