kopia lustrzana https://github.com/c9/core
another fix for error handling in mini_require
rodzic
59bea99812
commit
ac11de256d
|
@ -412,7 +412,11 @@ function loadText(path, cb) {
|
||||||
var xhr = new window.XMLHttpRequest();
|
var xhr = new window.XMLHttpRequest();
|
||||||
xhr.open("GET", path, true);
|
xhr.open("GET", path, true);
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
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.onabort = xhr.onerror = function(e) { cb(e); };
|
||||||
xhr.send("");
|
xhr.send("");
|
||||||
}
|
}
|
||||||
|
@ -425,12 +429,9 @@ var loadScript = function(path, id, callback) {
|
||||||
if (!/https?:/.test(path))
|
if (!/https?:/.test(path))
|
||||||
path = host + path;
|
path = host + path;
|
||||||
var cb = function(e, val, deps) {
|
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 = {
|
nextModule = { name: id, deps: deps };
|
||||||
name: id,
|
|
||||||
deps: deps
|
|
||||||
};
|
|
||||||
window.eval(val + "\n//# sourceURL=" + path);
|
window.eval(val + "\n//# sourceURL=" + path);
|
||||||
callback(null, id);
|
callback(null, id);
|
||||||
return define.loaded[id];
|
return define.loaded[id];
|
||||||
|
@ -547,9 +548,7 @@ function post(path, val, progress, cb) {
|
||||||
cb(null, xhr.responseText, xhr);
|
cb(null, xhr.responseText, xhr);
|
||||||
};
|
};
|
||||||
xhr.onreadystatechange = function(e) { progress(xhr.responseText, xhr); };
|
xhr.onreadystatechange = function(e) { progress(xhr.responseText, xhr); };
|
||||||
xhr.onabort = xhr.onerror = function(e) {
|
xhr.onabort = xhr.onerror = function(e) { cb(e); };
|
||||||
xhr && cb(e);
|
|
||||||
};
|
|
||||||
xhr.send(val);
|
xhr.send(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue