Преглед изворни кода

fixed issue when network error occurs

Gildas пре 7 година
родитељ
комит
17f05e81a8
1 измењених фајлова са 5 додато и 1 уклоњено
  1. 5 1
      lib/single-file/single-file-browser.js

+ 5 - 1
lib/single-file/single-file-browser.js

@@ -63,7 +63,11 @@ this.SingleFile = this.SingleFile || (() => {
 				return options && options.asDataURI ? "data:base64," : "";
 			}
 			if (resourceContent.status >= 400 && superFetch.hostFetch) {
-				resourceContent = await superFetch.hostFetch(resourceURL);
+				try {
+					resourceContent = await superFetch.hostFetch(resourceURL);
+				} catch (error) {
+					return options && options.asDataURI ? "data:base64," : "";
+				}
 			}
 			if (resourceContent.status >= 400) {
 				resourceContent = options && options.asDataURI ? "data:base64," : "";