Commit a71c688d authored by Alex Beregszaszi's avatar Alex Beregszaszi

Enclose JSON conversion in try/catch

parent f36b9d9a
...@@ -8,9 +8,12 @@ function Config (storage) { ...@@ -8,9 +8,12 @@ function Config (storage) {
this.items = {} this.items = {}
// load on instantiation // load on instantiation
var config = storage.get(CONFIG_FILE) try {
if (config) { var config = storage.get(CONFIG_FILE)
this.items = JSON.parse(config) if (config) {
this.items = JSON.parse(config)
}
} catch (exception) {
} }
this.exists = function (key) { this.exists = function (key) {
...@@ -23,7 +26,10 @@ function Config (storage) { ...@@ -23,7 +26,10 @@ function Config (storage) {
this.set = function (key, content) { this.set = function (key, content) {
this.items[key] = content this.items[key] = content
storage.set(CONFIG_FILE, JSON.stringify(this.items)) try {
storage.set(CONFIG_FILE, JSON.stringify(this.items))
} catch (exception) {
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment