summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2015-03-11 22:33:56 +0000
committerChristopher Baines <cb15g11@soton.ac.uk>2015-03-11 22:33:56 +0000
commitaee7cbb090494b0c8db1219ce7f2fd072a835a2a (patch)
treeed95c0595fa71027a1e885901e25a0945b81e9e4
parenteb98755f79bbd4208dc7c042092f4033ed751a3b (diff)
downloadleaflet-soton-aee7cbb090494b0c8db1219ce7f2fd072a835a2a.tar
leaflet-soton-aee7cbb090494b0c8db1219ce7f2fd072a835a2a.tar.gz
Improved error handling
-rwxr-xr-xcreate-data.js56
1 files changed, 47 insertions, 9 deletions
diff --git a/create-data.js b/create-data.js
index d566704..fb162b8 100755
--- a/create-data.js
+++ b/create-data.js
@@ -105,7 +105,7 @@ pgql.connect('tcp://' + config.user + ':' +
features: features
};
- callback();
+ callback(err);
});
},
function(callback) {
@@ -114,7 +114,8 @@ pgql.connect('tcp://' + config.user + ':' +
type: "FeatureCollection",
features: features
};
- callback();
+
+ callback(err);
});
},
function(callback) {
@@ -125,6 +126,10 @@ pgql.connect('tcp://' + config.user + ':' +
});
}
], function(err) {
+ if (err) {
+ callback(err);
+ }
+
getBuildingImages(buildings, function(err) {
getLibraryData(library_data, function(err, features) {
collections.buildingParts.features.push.apply(collections.buildingParts.features, features);
@@ -343,7 +348,7 @@ function processBuildingParts(buildingParts, callback) {
function linkToLoc(loc, reverse) {
if (reverse)
loc = loc.slice(0).reverse();
- return "http://cbaines.net/sum/#1/22/" + loc.join('/');
+ return "http://cbaines.net/leaflet-soton/examples/full.html#1/22/" + loc.join('/');
}
function getPartToLevelMap(buildingRelations, buildings, callback) {
@@ -695,6 +700,11 @@ function createBuildingParts(buildings, callback) {
async.parallel([getBuildingParts, getBuildingEntrances, getBuildingRelations, getPortals],
function(err, results) {
+ if (err) {
+ callback(err);
+ return;
+ }
+
// The objects in this array are modified
var buildingParts = results[0];
var buildingEntrances = results[1];
@@ -1160,6 +1170,9 @@ SELECT DISTINCT * WHERE {\
console.error("error in getPortals");
console.error("query " + query);
console.error(err);
+
+ callback(err);
+ return;
}
portals = [];
@@ -1262,6 +1275,9 @@ SELECT * WHERE {\
console.error("error in getUniWorkstations");
console.error(err);
console.error("query " + query);
+
+ callback(err);
+ return;
}
var results = data.results.bindings;
@@ -1331,6 +1347,9 @@ SELECT DISTINCT * WHERE {\
console.error("error in getPrinters");
console.error(err);
console.error("query " + query);
+
+ callback(err);
+ return;
}
var printerLabelByURI = {};
@@ -2079,21 +2098,40 @@ function sparqlQuery(query, callback) {
});
res.on('end',function(){
- if (res.statusCode !== 200)
- callback(data);
+ //if (res.statusCode !== 200) {
+ // callback(data);
+ //}
try {
var obj = JSON.parse(data);
} catch (err) {
- console.error("Error parsing output from sparql.data.southampton.ac.uk");
- console.error(data);
+ var error = "Error parsing output from sparql.data.southampton.ac.uk";
+ error += "\n\n";
- console.error(query);
+ error += "Query way:";
+ error += "\n\n";
+
+ error += query;
+ error += "\n\n";
+
+ error += "Response was:\n"
+ error += data;
+
+ error += "Parse error:\n"
+ error += err;
+ error += "\n\n";
+
+ callback(error);
- callback(err);
return;
}
+ if (obj == null) {
+ callback("obj is null");
+
+ return;
+ }
+
callback(null, obj);
})
}).on('error', function(e) {