From ac11de256d361de09c3a091a41a48e179398e7eb Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 9 Jan 2016 03:42:15 +0400 Subject: [PATCH] another fix for error handling in mini_require --- .../build_support/mini_require.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/node_modules/architect-build/build_support/mini_require.js b/node_modules/architect-build/build_support/mini_require.js index 3da2f16e..5c6b793c 100644 --- a/node_modules/architect-build/build_support/mini_require.js +++ b/node_modules/architect-build/build_support/mini_require.js @@ -412,7 +412,11 @@ function loadText(path, cb) { var xhr = new window.XMLHttpRequest(); xhr.open("GET", path, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); - xhr.onload = function(e) { cb(null, xhr.responseText, xhr); }; + xhr.onload = function(e) { + if (xhr.status > 399 && xhr.status < 600) + return cb(xhr); + cb(null, xhr.responseText, xhr); + }; xhr.onabort = xhr.onerror = function(e) { cb(e); }; xhr.send(""); } @@ -425,12 +429,9 @@ var loadScript = function(path, id, callback) { if (!/https?:/.test(path)) path = host + path; var cb = function(e, val, deps) { - if (e) console.error("Couldn't load module " + module, e); + if (e) return processLoadQueue({ id: id, path: path }); - nextModule = { - name: id, - deps: deps - }; + nextModule = { name: id, deps: deps }; window.eval(val + "\n//# sourceURL=" + path); callback(null, id); return define.loaded[id]; @@ -547,9 +548,7 @@ function post(path, val, progress, cb) { cb(null, xhr.responseText, xhr); }; xhr.onreadystatechange = function(e) { progress(xhr.responseText, xhr); }; - xhr.onabort = xhr.onerror = function(e) { - xhr && cb(e); - }; + xhr.onabort = xhr.onerror = function(e) { cb(e); }; xhr.send(val); }