Skip to content

Commit ecdd84c

Browse files
committed
better error message when fails to update snippets
1 parent fbff9ac commit ecdd84c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

update-code-snippets.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// updates code snippets from remote repo
2-
// See README.md
3-
var snippets = JSON.parse(localStorage.scriptSnippets);
2+
// needs to run in the secondary DevTools window (undocked)
3+
// see "Updating local code snippets"
4+
var source = localStorage.scriptSnippets;
5+
if (typeof source === 'undefined') {
6+
throw new Error('Cannot find scriptSnippets, are you running in the secondary DevTools?\n' +
7+
'see https://github.com/bahmutov/code-snippets#updating-local-code-snippets');
8+
}
9+
var snippets = JSON.parse(source);
410
console.log('I have', snippets.length, 'code snippets');
511
console.table(snippets);
612

0 commit comments

Comments
 (0)