From e5b54d9b6a7280f5baf13b6a2c35148cf5f3d953 Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 9 Aug 2016 16:11:46 -0700 Subject: [PATCH] Bubble up InvalidStateErrors and log them These may be indicative of a potentially fatal lack of disk space. // FREEBIE --- .../indexeddb-backbonejs-adapter/backbone-indexeddb.js | 8 ++++++++ js/background.js | 4 ++++ js/components.js | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/components/indexeddb-backbonejs-adapter/backbone-indexeddb.js b/components/indexeddb-backbonejs-adapter/backbone-indexeddb.js index 6a094d9e..2ae8ad1e 100644 --- a/components/indexeddb-backbonejs-adapter/backbone-indexeddb.js +++ b/components/indexeddb-backbonejs-adapter/backbone-indexeddb.js @@ -562,7 +562,15 @@ // Executes a given command on the driver. If not started, just stacks up one more element. execute: function (message) { if (this.started) { + try { this.driver.execute(message[2].storeName || message[1].storeName, message[0], message[1], message[2]); // Upon messages, we execute the query + } catch (e) { + if (e.name === 'InvalidStateError') { + var f = window.onInvalidStateError; + if (f) f(e); + } + throw e; + } } else if (this.failed) { message[2].error(); } else { diff --git a/js/background.js b/js/background.js index 38eb34af..50f92922 100644 --- a/js/background.js +++ b/js/background.js @@ -4,6 +4,10 @@ ;(function() { 'use strict'; + window.onInvalidStateError = function(e) { + console.log(e); + }; + console.log('background page reloaded'); // register some chrome listeners if (chrome.notifications) { diff --git a/js/components.js b/js/components.js index 7d72340a..e94a5bee 100644 --- a/js/components.js +++ b/js/components.js @@ -21920,7 +21920,15 @@ return jQuery; // Executes a given command on the driver. If not started, just stacks up one more element. execute: function (message) { if (this.started) { + try { this.driver.execute(message[2].storeName || message[1].storeName, message[0], message[1], message[2]); // Upon messages, we execute the query + } catch (e) { + if (e.name === 'InvalidStateError') { + var f = window.onInvalidStateError; + if (f) f(e); + } + throw e; + } } else if (this.failed) { message[2].error(); } else {