From cb5b2353d546d76d55af64ce512e470fea2d48fd Mon Sep 17 00:00:00 2001 From: dsk7 Date: Sat, 10 Jan 2015 16:21:27 +0100 Subject: [PATCH 1/2] Continue rendering in case of missing stylesheets propapage the getText()-errors up through replace.links() and replace.stylesheets() --- src/replace.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/replace.js b/src/replace.js index 7286fd6..30778a3 100644 --- a/src/replace.js +++ b/src/replace.js @@ -75,6 +75,9 @@ EPUBJS.replace.links = function(_store, full, done, link){ setTimeout(function(){ done(url, full); }, 5); //-- Allow for css to apply before displaying chapter + }, function(reason) { + // we were unable to replace the style sheets + done(null); }); }else{ _store.getUrl(full).then(done, function(reason) { @@ -100,10 +103,12 @@ EPUBJS.replace.stylesheets = function(_store, full) { deferred.resolve(url); - }, function(e) { - console.error(e); + }, function(reason) { + deferred.reject(reason); }); + }, function(reason) { + deferred.reject(reason); }); return deferred.promise; From 1114d13db93534e61f4e4dcc1f1ef8b95b034053 Mon Sep 17 00:00:00 2001 From: dsk7 Date: Sat, 10 Jan 2015 16:39:38 +0100 Subject: [PATCH 2/2] make Unarchiver.prototype.getText reject the promise if the entry is not contained in the zip file --- src/unarchiver.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unarchiver.js b/src/unarchiver.js index 4944f55..78824b1 100644 --- a/src/unarchiver.js +++ b/src/unarchiver.js @@ -68,7 +68,10 @@ EPUBJS.Unarchiver.prototype.getText = function(url, encoding){ var _URL = window.URL || window.webkitURL || window.mozURL; if(!entry) { - console.warn("File not found in the contained epub:", url); + deferred.reject({ + message : "File not found in the epub: " + url, + stack : new Error().stack + }); return deferred.promise; }