From 5a17e41f7ff4711b1b680fc74572dce6a943ad1f Mon Sep 17 00:00:00 2001 From: Eric Shull Date: Sun, 24 Dec 2017 14:47:51 -0500 Subject: [PATCH] Wrap Xhr request sending in a try. --- saveSvgAsPng.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/saveSvgAsPng.js b/saveSvgAsPng.js index dd8d604..5a1b49a 100644 --- a/saveSvgAsPng.js +++ b/saveSvgAsPng.js @@ -202,7 +202,12 @@ oReq.addEventListener('abort', transferFailed); oReq.open('GET', font.url); oReq.responseType = 'arraybuffer'; - oReq.send(); + + try { + oReq.send(); + } catch (e) { + transferFailed(); + } function fontLoaded() { // TODO: it may be also worth to wait until fonts are fully loaded before @@ -214,7 +219,9 @@ function transferFailed(e) { console.warn('Failed to load font from: ' + font.url); - console.warn(e) + if(e) { + console.warn(e) + } css += font.text + '\n'; processFontQueue(queue); } @@ -228,7 +235,6 @@ processFontQueue(queue) }, 0); } - } }