Skip to content

Commit

Permalink
Merge pull request #75 from iam4x/master
Browse files Browse the repository at this point in the history
Catch `QuotaExceededError`
  • Loading branch information
mjackson committed Oct 7, 2015
2 parents aeb8ec8 + c54f8ef commit 64af5ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lib
umd
node_modules
11 changes: 10 additions & 1 deletion modules/DOMStateStorage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warning from 'warning'

/*eslint-disable no-empty */
const KeyPrefix = '@@History/'

Expand All @@ -6,7 +8,14 @@ function createKey(key) {
}

export function saveState(key, state) {
window.sessionStorage.setItem(createKey(key), JSON.stringify(state))
try {
window.sessionStorage.setItem(createKey(key), JSON.stringify(state))
} catch (error) {
if (error.name === 'QuotaExceededError')
return warning(null, 'sessionStore is not accessible in incognito mode')

throw error
}
}

export function readState(key) {
Expand Down

0 comments on commit 64af5ea

Please sign in to comment.