[gnome-maps/wip/mlundblad/transit-service-discovery: 2/3] Move common error messages to TransitPlan



commit 8f4c5049b4dba5df2740b7b90459e0e3781d57d6
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Aug 27 21:39:24 2019 +0200

    Move common error messages to TransitPlan
    
    Add methods to flag errors to the TransitPlan
    module from the OpenTripPlanner plugin to
    allow re-using them from the transit router
    and eventual new transit provider plugins.

 po/POTFILES.in                        |  1 -
 src/transitPlan.js                    | 14 +++++++++++++-
 src/transitplugins/openTripPlanner.js |  6 +++---
 3 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 529f516..33c68c1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -58,4 +58,3 @@ src/transitOptionsPanel.js
 src/transitPlan.js
 src/translations.js
 src/utils.js
-src/transitplugins/openTripPlanner.js
diff --git a/src/transitPlan.js b/src/transitPlan.js
index 6953394..d30f9db 100644
--- a/src/transitPlan.js
+++ b/src/transitPlan.js
@@ -137,6 +137,18 @@ var Plan = GObject.registerClass({
         this.emit('error', msg);
     }
 
+    noRouteFound() {
+        this.emit('error', _("No route found."));
+    }
+
+    noTimetable() {
+        this.emit('error', _("No timetable data found for this route."));
+    }
+
+    requestFailed() {
+        this.emit('error', _("Route request failed."));
+    }
+
     _createBBox() {
         let bbox = new Champlain.BoundingBox();
         this._itineraries.forEach(function(itinerary) {
@@ -718,4 +730,4 @@ function sortItinerariesByDepartureAsc(first, second) {
 
 function sortItinerariesByArrivalDesc(first, second) {
     return first.arrival < second.arrival;
-}
\ No newline at end of file
+}
diff --git a/src/transitplugins/openTripPlanner.js b/src/transitplugins/openTripPlanner.js
index 2a46756..d42e71b 100644
--- a/src/transitplugins/openTripPlanner.js
+++ b/src/transitplugins/openTripPlanner.js
@@ -612,7 +612,7 @@ var OpenTripPlanner = class OpenTripPlanner {
             this.plan.noMoreResults();
         } else {
             this._reset();
-            this.plan.error(_("No route found."));
+            this.plan.noRouteFound();
         }
     }
 
@@ -645,11 +645,11 @@ var OpenTripPlanner = class OpenTripPlanner {
 
                 } else {
                     this._reset();
-                    this.plan.error(_("No timetable data found for this route."));
+                    this.plan.noTimetable();
                 }
             } else {
                 this._reset();
-                this.plan.error(_("Route request failed."));
+                this.plan.requestFailed();
             }
         });
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]