From 6d4caf855d008adcb4deded897decbaa6c212be7 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 4 Mar 2015 11:30:20 +0100 Subject: [PATCH] Fixed error handling. --- js/h5p-content-upgrade-worker.js | 2 +- js/h5p-content-upgrade.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/h5p-content-upgrade-worker.js b/js/h5p-content-upgrade-worker.js index c201b54..4cd0047 100644 --- a/js/h5p-content-upgrade-worker.js +++ b/js/h5p-content-upgrade-worker.js @@ -23,7 +23,7 @@ var messageHandlers = { postMessage({ action: 'error', id: job.id, - err: err + err: err.message ? err.message : err }); return; diff --git a/js/h5p-content-upgrade.js b/js/h5p-content-upgrade.js index 05667d8..cd50b86 100644 --- a/js/h5p-content-upgrade.js +++ b/js/h5p-content-upgrade.js @@ -381,6 +381,8 @@ * @param {Function} next */ ContentUpgrade.prototype.loadScript = function (url, next) { + var self = this; + if (scriptsCache[url] !== undefined) { next(); return; @@ -406,14 +408,16 @@ * */ ContentUpgrade.prototype.printError = function (error) { + var self = this; + if (error.type === 'errorParamsBroken') { - error = info.errorContent.replace('%id', error.id) + ' ' + info.errorParamsBroken; // TODO: Translate! + error = info.errorContent.replace('%id', error.id) + ' ' + info.errorParamsBroken; } else if (error.type === 'scriptMissing') { - error.err = info.errorScript.replace('%lib', error.library); + error = info.errorScript.replace('%lib', error.library); } - self.setStatus('

' + info.error + '
' + error.err + '

'); + self.setStatus('

' + info.error + '
' + error + '

'); }; })(H5P.jQuery, H5P.Version);