Skip to content

Instantly share code, notes, and snippets.

@akgupta
Created March 17, 2012 22:12
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save akgupta/2065777 to your computer and use it in GitHub Desktop.
Save akgupta/2065777 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