Parcourir la source

fixed issue when network error occurs

Gildas il y a 7 ans
Parent
commit
17f05e81a8
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  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," : "";