aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/node
diff options
context:
space:
mode:
authorGravatar Filippo De Santis <filippo.desantis@gmail.com>2016-09-02 12:28:45 +0200
committerGravatar Filippo De Santis <filippo.desantis@gmail.com>2016-09-02 12:28:45 +0200
commit1647097d40b2826597356671fd6fd8b80492ee46 (patch)
tree7f98294f55d5aa4dc9394ca79cad2701f7ec31d2 /examples/node
parent79620aaa1052fd02539a36caa63cbe24a2087b0f (diff)
Add return after calling callback(err)
Diffstat (limited to 'examples/node')
-rw-r--r--examples/node/dynamic_codegen/route_guide/route_guide_client.js7
-rw-r--r--examples/node/static_codegen/route_guide/route_guide_client.js7
2 files changed, 12 insertions, 2 deletions
diff --git a/examples/node/dynamic_codegen/route_guide/route_guide_client.js b/examples/node/dynamic_codegen/route_guide/route_guide_client.js
index 775b9addbf..b7550b201a 100644
--- a/examples/node/dynamic_codegen/route_guide/route_guide_client.js
+++ b/examples/node/dynamic_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');
diff --git a/examples/node/static_codegen/route_guide/route_guide_client.js b/examples/node/static_codegen/route_guide/route_guide_client.js
index ecde78616b..e16de44a1a 100644
--- a/examples/node/static_codegen/route_guide/route_guide_client.js
+++ b/examples/node/static_codegen/route_guide/route_guide_client.js
@@ -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');