go-tour: handle disabled cookies graciously
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/189200043
diff --git a/static/js/services.js b/static/js/services.js
index c507af2..e045041 100755
--- a/static/js/services.js
+++ b/static/js/services.js
@@ -77,7 +77,9 @@
// Local storage, persistent to page refreshing.
factory('storage', ['$window',
function(win) {
- if (win.localStorage) {
+ try {
+ // This will raise an exception if cookies are disabled.
+ win.localStorage = win.localStorage;
return {
get: function(key) {
return win.localStorage.getItem(key);
@@ -86,13 +88,14 @@
win.localStorage.setItem(key, val);
}
};
+ } catch (e) {
+ return {
+ get: function() {
+ return null;
+ },
+ set: function() {}
+ };
}
- return {
- get: function() {
- return null;
- },
- set: function() {}
- };
}
]).