From 67ada1ba73ddb0fe9d69b4ea63219ad7cb7acb84 Mon Sep 17 00:00:00 2001 From: kwkofler Date: Sat, 29 Mar 2014 13:23:51 -0400 Subject: [PATCH 1/2] Issue #136 - Added more verbose errors for situations where Private Browsing prevents DB access --- src/providers/indexeddb.js | 3 ++- src/providers/websql.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/providers/indexeddb.js b/src/providers/indexeddb.js index 2658163..4975d60 100644 --- a/src/providers/indexeddb.js +++ b/src/providers/indexeddb.js @@ -9,6 +9,7 @@ define(function(require) { var IDB_RW = require('src/constants').IDB_RW; var IDB_RO = require('src/constants').IDB_RO; + var Errors = require('src/errors'); function IndexedDBContext(db, mode) { var transaction = db.transaction(FILE_STORE_NAME, mode); @@ -112,7 +113,7 @@ define(function(require) { callback(null, firstAccess); }; openRequest.onerror = function onerror(error) { - callback(error); + callback(new Errors.EINVAL('IndexedDB cannot be accessed. If private browsing is enabled, disable it.')); }; }; IndexedDB.prototype.getReadOnlyContext = function() { diff --git a/src/providers/websql.js b/src/providers/websql.js index 4101de1..1b84deb 100644 --- a/src/providers/websql.js +++ b/src/providers/websql.js @@ -5,6 +5,7 @@ define(function(require) { var WSQL_SIZE = require('src/constants').WSQL_SIZE; var WSQL_DESC = require('src/constants').WSQL_DESC; var u8toArray = require('src/shared').u8toArray; + var Errors = require('src/errors'); function WebSQLContext(db, isReadOnly) { var that = this; @@ -116,6 +117,9 @@ define(function(require) { } function onError(transaction, error) { + if (error.code === 5) { + callback(new Errors.EINVAL('WebSQL access not authorized. If private browsing is enabled, disable it.')); + } callback(error); } function onSuccess(transaction, result) { From e925ec3556071ace78056e704931712d53005b53 Mon Sep 17 00:00:00 2001 From: kwkofler Date: Sun, 30 Mar 2014 12:48:04 -0400 Subject: [PATCH 2/2] Changed WebSQL error to be more in line with IndexedDB error. --- src/providers/websql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/websql.js b/src/providers/websql.js index 1b84deb..c765f8a 100644 --- a/src/providers/websql.js +++ b/src/providers/websql.js @@ -118,7 +118,7 @@ define(function(require) { function onError(transaction, error) { if (error.code === 5) { - callback(new Errors.EINVAL('WebSQL access not authorized. If private browsing is enabled, disable it.')); + callback(new Errors.EINVAL('WebSQL cannot be accessed. If private browsing is enabled, disable it.')); } callback(error); }