Connection.loadFromURL was swallowing all the errors instead of passing them along

This commit is contained in:
Bryan Housel
2014-12-17 21:39:48 -05:00
parent 0c881ef9f2
commit b9ac4b95d1
2 changed files with 10 additions and 8 deletions
+4 -4
View File
@@ -42,10 +42,10 @@ iD.Connection = function() {
};
connection.loadFromURL = function(url, callback) {
function done(dom) {
return callback(null, parse(dom));
function done(err, dom) {
return callback(err, parse(dom));
}
return d3.xml(url).get().on('load', done);
return d3.xml(url).get(done);
};
connection.loadEntity = function(id, callback) {
@@ -137,7 +137,7 @@ iD.Connection = function() {
};
function parse(dom) {
if (!dom || !dom.childNodes) return new Error('Bad request');
if (!dom || !dom.childNodes) return;
var root = dom.childNodes[0],
children = root.childNodes,
+6 -4
View File
@@ -55,10 +55,12 @@ window.iD = function () {
}
connection.on('load.context', function loadContext(err, result) {
if (altGraph) {
_.each(result.data, function(entity) { altGraph.replace(entity); });
} else {
history.merge(result.data, result.extent);
if (!err) {
if (altGraph) {
_.each(result.data, function(entity) { altGraph.replace(entity); });
} else {
history.merge(result.data, result.extent);
}
}
});