From 96b557a0a106eadef282591d162dc6020c9bd88d Mon Sep 17 00:00:00 2001 From: Brian Stell Date: Wed, 4 Nov 2015 17:16:29 -0800 Subject: [PATCH 1/2] Slight tuneup to window.onerror event handler. --- .../gae_server/www/js/tachyfont/tachyfont.js | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/run_time/src/gae_server/www/js/tachyfont/tachyfont.js b/run_time/src/gae_server/www/js/tachyfont/tachyfont.js index bbe79a0f..16c27c26 100644 --- a/run_time/src/gae_server/www/js/tachyfont/tachyfont.js +++ b/run_time/src/gae_server/www/js/tachyfont/tachyfont.js @@ -113,24 +113,26 @@ tachyfont.delayedReportError_ = function(obj) { }; -/** - * Report any uncaught errors. - * - * @param {Event} error The error information. - * @private - */ -tachyfont.windowOnError_ = function(error) { - var errorObj = {}; - errorObj['message'] = error.error; - errorObj['url'] = error.filename; - errorObj['lineNumber'] = error.lineno; - tachyfont.reportError_(tachyfont.Error_.WINDOW_ON_ERROR, errorObj); -}; - if (window.addEventListener) { + /** + * Report any uncaught errors. + * + * @param {Event} error The error information. + * @private + */ + tachyfont.windowOnError_ = function(error) { + var errorObj = {}; + errorObj['message'] = error['message']; + errorObj['filename'] = error['filename']; + errorObj['lineno'] = error['lineno']; + errorObj['colno'] = error['colno']; + if (error.error) { + errorObj['stack'] = error['error']['stack'].substring(0, 1000); + } + var errorStr = JSON.stringify(errorObj); + tachyfont.reportError_(tachyfont.Error_.WINDOW_ON_ERROR, errorStr); + }; window.addEventListener('error', tachyfont.windowOnError_, false); -} else if (window.attachEvent) { // for versions previous to IE9 - window.attachEvent('onerror', tachyfont.windowOnError_); } if (goog.DEBUG) { From 0e958630ce562f623bed650fe8d2d04f02d08e4f Mon Sep 17 00:00:00 2001 From: Brian Stell Date: Wed, 4 Nov 2015 17:18:57 -0800 Subject: [PATCH 2/2] Add an error report for when delete IDB fails. --- .../www/js/tachyfont/incrementalfont.js | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/run_time/src/gae_server/www/js/tachyfont/incrementalfont.js b/run_time/src/gae_server/www/js/tachyfont/incrementalfont.js index 1c2beba4..fe2757a7 100644 --- a/run_time/src/gae_server/www/js/tachyfont/incrementalfont.js +++ b/run_time/src/gae_server/www/js/tachyfont/incrementalfont.js @@ -142,6 +142,7 @@ tachyfont.IncrementalFont.Error_ = { NOT_USING_PERSISTED_DATA: '41', FINGERPRINT_MISMATCH: '42', CHARS_PER_SEGMENT: '43', + DELETE_IDB: '44', END: '00' }; @@ -391,16 +392,30 @@ tachyfont.IncrementalFont.obj_.prototype.dropDb_ = function() { tachyfont.IncrementalFont.obj_.prototype.accessDb_ = function(dropDb) { // Close the database if it is open. this.closeDb_(); + var weight = this.fontInfo.getWeight(); + var dbName = this.getDbName_(); this.getIDB_ = goog.Promise.resolve() .then(function() { if (dropDb) { - return tachyfont.Persist.deleteDatabase(this.getDbName_(), - this.fontInfo.getWeight()); + return tachyfont.Persist.deleteDatabase(dbName, weight) + .thenCatch(function() { + tachyfont.IncrementalFont.reportError_( + tachyfont.IncrementalFont.Error_.DELETE_IDB, weight, + 'accessDb'); + return goog.Promise.reject(); + }); + } }.bind(this)) .then(function() { - return tachyfont.Persist.openIndexedDB(this.getDbName_(), - this.fontInfo.getWeight()); + return tachyfont.Persist.openIndexedDB(dbName, weight) + .thenCatch(function() { + tachyfont.IncrementalFont.reportError_( + tachyfont.IncrementalFont.Error_.OPEN_IDB, weight, + 'accessDb'); + return goog.Promise.reject('failed to open IDB'); + }); + }.bind(this)); return this.getIDB_;