Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2921eee

Browse filesBrowse files
committed
Merge pull request sdether#25 from jedapostol/issue_24
Any call to local storage must be wrapped inside a try catch
2 parents d85d4d7 + 0041f29 commit 2921eee
Copy full SHA for 2921eee

File tree

Expand file treeCollapse file tree

1 file changed

+10
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-2
lines changed

‎js/history.js

Copy file name to clipboardExpand all lines: js/history.js
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ var Josh = Josh || {};
2828
var _key = config.key || 'josh.history';
2929

3030
if (_storage) {
31-
var data = _storage.getItem(_key);
31+
try {
32+
var data = _storage.getItem(_key);
33+
} catch(e) {
34+
_console.log("Error accessing storage");
35+
}
3236
if (data) {
3337
_history = JSON.parse(data);
3438
_searchCursor = _cursor = _history.length - 1;
@@ -38,7 +42,11 @@ var Josh = Josh || {};
3842
}
3943
function save() {
4044
if (_storage) {
41-
_storage.setItem(_key, JSON.stringify(_history));
45+
try {
46+
_storage.setItem(_key, JSON.stringify(_history));
47+
} catch(e) {
48+
_console.log("Error accessing storage");
49+
}
4250
}
4351
}
4452

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.