From dc12fe9b4dd8457bb42f8b4b8ad088ad4448961e Mon Sep 17 00:00:00 2001 From: Zarko Hristovski Date: Mon, 29 Aug 2016 11:51:20 +0200 Subject: [PATCH] Capture a rejected deviceReady correctly --- dist/localforage-cordovasqlitedriver.es6.js | 4 +++- dist/localforage-cordovasqlitedriver.js | 4 +++- lib/cordova-sqlite.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dist/localforage-cordovasqlitedriver.es6.js b/dist/localforage-cordovasqlitedriver.es6.js index 8dbc92b..34a60bf 100644 --- a/dist/localforage-cordovasqlitedriver.es6.js +++ b/dist/localforage-cordovasqlitedriver.es6.js @@ -40,7 +40,7 @@ var deviceReady = new Promise(function (resolve, reject) { } }); -var openDatabasePromise = deviceReady.catch(Promise.resolve).then(function () { +var openDatabasePromise = deviceReady.then(function () { return new Promise(function (resolve, reject) { if (typeof sqlitePlugin !== 'undefined' && typeof sqlitePlugin.openDatabase === 'function') { resolve(sqlitePlugin.openDatabase); @@ -48,6 +48,8 @@ var openDatabasePromise = deviceReady.catch(Promise.resolve).then(function () { reject('SQLite plugin is not present.'); } }); +}).catch(function () { + return Promise.resolve(); }); // // If cordova is not present, we can stop now. diff --git a/dist/localforage-cordovasqlitedriver.js b/dist/localforage-cordovasqlitedriver.js index f6b925e..49a23fc 100644 --- a/dist/localforage-cordovasqlitedriver.js +++ b/dist/localforage-cordovasqlitedriver.js @@ -46,7 +46,7 @@ } }); - var openDatabasePromise = deviceReady.catch(Promise.resolve).then(function () { + var openDatabasePromise = deviceReady.then(function () { return new Promise(function (resolve, reject) { if (typeof sqlitePlugin !== 'undefined' && typeof sqlitePlugin.openDatabase === 'function') { resolve(sqlitePlugin.openDatabase); @@ -54,6 +54,8 @@ reject('SQLite plugin is not present.'); } }); + }).catch(function () { + return Promise.resolve(); }); // // If cordova is not present, we can stop now. diff --git a/lib/cordova-sqlite.js b/lib/cordova-sqlite.js index 9a75534..ef5b9ab 100644 --- a/lib/cordova-sqlite.js +++ b/lib/cordova-sqlite.js @@ -13,7 +13,7 @@ var deviceReady = new Promise(function(resolve, reject) { } }); -export var openDatabasePromise = deviceReady.catch(Promise.resolve).then(function() { +export var openDatabasePromise = deviceReady.then(function() { return new Promise(function(resolve, reject) { if (typeof sqlitePlugin !== 'undefined' && typeof sqlitePlugin.openDatabase === 'function') { @@ -22,4 +22,6 @@ export var openDatabasePromise = deviceReady.catch(Promise.resolve).then(functio reject('SQLite plugin is not present.'); } }); +}).catch(function() { + return Promise.resolve(); });