summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-03-13 23:51:25 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-03-13 23:51:25 +0300
commita566460a56afef809d8d21b24bc4e12f7dd1289a (patch)
treed25517f11519fc2f49252424f78c044523e079bd
parent9eeb7c8bf546a9d162c29d3100a37354d376abc9 (diff)
cookies: catch json.parse errors
-rw-r--r--cookies-storage.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/cookies-storage.js b/cookies-storage.js
index 25d7f1c..8c9231b 100644
--- a/cookies-storage.js
+++ b/cookies-storage.js
@@ -35,7 +35,13 @@ module.exports = {
async get() {
if (!(await exists(storageFileName)))
return []
- return JSON.parse(await fs.readFile(storageFileName, 'utf-8'))
+
+ try {
+ return JSON.parse(await fs.readFile(storageFileName, 'utf-8'))
+ } catch (e) {
+ console.error(e)
+ return []
+ }
},
setFileName(name) {