Skip to content
Snippets Groups Projects
Commit 1647097d authored by Filippo De Santis's avatar Filippo De Santis
Browse files

Add return after calling callback(err)

parent 79620aaa
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,7 @@ function runGetFeature(callback) { ...@@ -55,6 +55,7 @@ function runGetFeature(callback) {
function featureCallback(error, feature) { function featureCallback(error, feature) {
if (error) { if (error) {
callback(error); callback(error);
return;
} }
if (feature.name === '') { if (feature.name === '') {
console.log('Found no feature at ' + console.log('Found no feature at ' +
...@@ -117,13 +118,17 @@ function runRecordRoute(callback) { ...@@ -117,13 +118,17 @@ function runRecordRoute(callback) {
string: 'db_path' string: 'db_path'
}); });
fs.readFile(path.resolve(argv.db_path), function(err, data) { fs.readFile(path.resolve(argv.db_path), function(err, data) {
if (err) callback(err); if (err) {
callback(err);
return;
}
var feature_list = JSON.parse(data); var feature_list = JSON.parse(data);
var num_points = 10; var num_points = 10;
var call = client.recordRoute(function(error, stats) { var call = client.recordRoute(function(error, stats) {
if (error) { if (error) {
callback(error); callback(error);
return;
} }
console.log('Finished trip with', stats.point_count, 'points'); console.log('Finished trip with', stats.point_count, 'points');
console.log('Passed', stats.feature_count, 'features'); console.log('Passed', stats.feature_count, 'features');
......
...@@ -56,6 +56,7 @@ function runGetFeature(callback) { ...@@ -56,6 +56,7 @@ function runGetFeature(callback) {
function featureCallback(error, feature) { function featureCallback(error, feature) {
if (error) { if (error) {
callback(error); callback(error);
return;
} }
var latitude = feature.getLocation().getLatitude(); var latitude = feature.getLocation().getLatitude();
var longitude = feature.getLocation().getLongitude(); var longitude = feature.getLocation().getLongitude();
...@@ -115,7 +116,10 @@ function runRecordRoute(callback) { ...@@ -115,7 +116,10 @@ function runRecordRoute(callback) {
string: 'db_path' string: 'db_path'
}); });
fs.readFile(path.resolve(argv.db_path), function(err, data) { fs.readFile(path.resolve(argv.db_path), function(err, data) {
if (err) callback(err); if (err) {
callback(err);
return;
}
// Transform the loaded features to Feature objects // Transform the loaded features to Feature objects
var feature_list = _.map(JSON.parse(data), function(value) { var feature_list = _.map(JSON.parse(data), function(value) {
var feature = new messages.Feature(); var feature = new messages.Feature();
...@@ -131,6 +135,7 @@ function runRecordRoute(callback) { ...@@ -131,6 +135,7 @@ function runRecordRoute(callback) {
var call = client.recordRoute(function(error, stats) { var call = client.recordRoute(function(error, stats) {
if (error) { if (error) {
callback(error); callback(error);
return;
} }
console.log('Finished trip with', stats.getPointCount(), 'points'); console.log('Finished trip with', stats.getPointCount(), 'points');
console.log('Passed', stats.getFeatureCount(), 'features'); console.log('Passed', stats.getFeatureCount(), 'features');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment