another fix for error handling in mini_require

pull/232/head
nightwing 2016-01-09 03:42:15 +04:00
rodzic 59bea99812
commit ac11de256d
1 zmienionych plików z 8 dodań i 9 usunięć

Wyświetl plik

@ -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);
}