Add return after calling callback(err)

pull/7967/head
Filippo De Santis 8 years ago
parent 79620aaa10
commit 1647097d40
  1. 7
      examples/node/dynamic_codegen/route_guide/route_guide_client.js
  2. 7
      examples/node/static_codegen/route_guide/route_guide_client.js

@ -55,6 +55,7 @@ function runGetFeature(callback) {
function featureCallback(error, feature) {
if (error) {
callback(error);
return;
}
if (feature.name === '') {
console.log('Found no feature at ' +
@ -117,13 +118,17 @@ function runRecordRoute(callback) {
string: 'db_path'
});
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 num_points = 10;
var call = client.recordRoute(function(error, stats) {
if (error) {
callback(error);
return;
}
console.log('Finished trip with', stats.point_count, 'points');
console.log('Passed', stats.feature_count, 'features');

@ -56,6 +56,7 @@ function runGetFeature(callback) {
function featureCallback(error, feature) {
if (error) {
callback(error);
return;
}
var latitude = feature.getLocation().getLatitude();
var longitude = feature.getLocation().getLongitude();
@ -115,7 +116,10 @@ function runRecordRoute(callback) {
string: 'db_path'
});
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
var feature_list = _.map(JSON.parse(data), function(value) {
var feature = new messages.Feature();
@ -131,6 +135,7 @@ function runRecordRoute(callback) {
var call = client.recordRoute(function(error, stats) {
if (error) {
callback(error);
return;
}
console.log('Finished trip with', stats.getPointCount(), 'points');
console.log('Passed', stats.getFeatureCount(), 'features');

Loading…
Cancel
Save