From d21da48778b711dd708954bc766ec6344d5374d5 Mon Sep 17 00:00:00 2001 From: Joey Baker Date: Tue, 10 Feb 2015 10:57:14 -0800 Subject: [PATCH] Catch put errors db.transaction can throw if the db wasn't properly initialize or if there is a WriteError --- idbstore.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/idbstore.js b/idbstore.js index 553104d..2c70413 100644 --- a/idbstore.js +++ b/idbstore.js @@ -447,8 +447,15 @@ var hasSuccess = false, result = null, putRequest; + + // db.transaction can throw if the db wasn't properly initialize or if there is a WriteError + try { + var putTransaction = this.db.transaction([this.storeName], this.consts.READ_WRITE); + } + catch (e){ + return void onError(e) + } - var putTransaction = this.db.transaction([this.storeName], this.consts.READ_WRITE); putTransaction.oncomplete = function () { var callback = hasSuccess ? onSuccess : onError; callback(result);