safeGet/safeSet: Don't bother if store.js is disabled.

For IE with localStorage disabled, store.js can raise exceptions if you
attempt to use it when it is "disabled" (cannot select a backend).
This commit is contained in:
Max Goodman
2013-09-13 16:15:27 -07:00
parent 2b245079d2
commit 641ef7ccf9

View File

@@ -37,6 +37,10 @@ r.ajax = function(request) {
}
store.safeGet = function(key, errorValue) {
if (store.disabled) {
return errorValue
}
// errorValue defaults to undefined, equivalent to the key being unset.
try {
return store.get(key)
@@ -51,6 +55,10 @@ store.safeGet = function(key, errorValue) {
}
store.safeSet = function(key, val) {
if (store.disabled) {
return false
}
// swallow exceptions upon storage set for non-trivial operations. returns
// a boolean value indicating success.
try {