Fixes #1382 gracefully recovers from local storage write error

This commit is contained in:
MatthieuLP
2021-04-14 16:12:29 +02:00
parent 40316b8e12
commit 1fce0f7c97

View File

@@ -57,12 +57,18 @@
* @param data {mixed}
*/
LocalStorageCache.prototype.set = function(data) {
if (this.ready) {
this.storage[this.key] = JSON.stringify({
timestamp: new Date().getTime(),
key: this.serverKey,
data: data
});
try {
if (this.ready) {
this.storage[this.key] = JSON.stringify({
timestamp: new Date().getTime(),
key: this.serverKey,
data: data
});
}
} catch (e) {
console.log("Local storage error:");
console.log(e);
console.log("Use of direct result from Piwigo API.");
}
};