Improve error handling for routing engines
authorTom Hughes <tom@compton.nu>
Wed, 30 Sep 2015 20:56:57 +0000 (21:56 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 30 Sep 2015 20:58:16 +0000 (21:58 +0100)
app/assets/javascripts/index/directions.js
app/assets/javascripts/index/directions/graphhopper.js
app/assets/javascripts/index/directions/mapquest.js
app/assets/javascripts/index/directions/mapzen.js
app/assets/javascripts/index/directions/osrm.js

index a5f3b00802c1afd68c9d5b4c58cf800e1ba6caec..a141045a3da13141d0b075f09303f654ee2a3f77 100644 (file)
@@ -189,7 +189,7 @@ OSM.Directions = function (map) {
         map.removeLayer(polyline);
 
         if (!dragging) {
-          alert(I18n.t('javascripts.directions.errors.no_route'));
+          $('#sidebar_content').html('<p class="search_results_error">' + I18n.t('javascripts.directions.errors.no_route') + '</p>');
         }
 
         return;
index 5a16f708cf33916a5ba1eccc7cd069b54c6b4eac..2d3455eeeda6ac1ca058de6f08bc71fc39c8f67a 100644 (file)
@@ -58,12 +58,15 @@ function GraphHopperEngine(id, vehicleType) {
             ]); // TODO does graphhopper map instructions onto line indices?
           }
 
-          callback(null, {
+          callback(false, {
             line: line,
             steps: steps,
             distance: path.distance,
             time: path.time / 1000
           });
+        },
+        error: function () {
+          callback(true);
         }
       });
     }
index 24be65de770024bfce445eef2d5486f33f44b527..f46d94dcff92447328a979bf5356a753f76aa5bb 100644 (file)
@@ -83,12 +83,15 @@ function MapQuestEngine(id, routeType) {
             steps.push([L.latLng(s.startPoint.lat, s.startPoint.lng), d, s.narrative, s.distance * 1000, lineseg]);
           }
 
-          callback(null, {
+          callback(false, {
             line: line,
             steps: steps,
             distance: data.route.distance * 1000,
             time: data.route.time
           });
+        },
+        error: function () {
+          callback(true);
         }
       });
     }
index 915e665f5d5e6acfbbfcd4960bf71fa235db16c7..02f0f418816f3689eb00b81873d9925cb6ca82f7 100644 (file)
@@ -93,6 +93,9 @@ function MapzenEngine(id, costing) {
           } else {
             callback(true);
           }
+        },
+        error: function () {
+          callback(true);
         }
       });
     }
index ab3bcff3605f36ee47173ba594512efadc4b3250..4a42d5dc96ea1e8d138c353afbd28824dc7bbdba 100644 (file)
@@ -84,12 +84,15 @@ function OSRMEngine() {
             steps.push([line[s[3]], s[0].split('-')[0], instText, s[2], line.slice(s[3], linesegend)]);
           }
 
-          callback(null, {
+          callback(false, {
             line: line,
             steps: steps,
             distance: data.route_summary.total_distance,
             time: data.route_summary.total_time
           });
+        },
+        error: function () {
+          callback(true);
         }
       });
     }