summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-01-23 10:52:30 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-01-23 10:52:30 +0100
commit358dd887d7e3f5a7ada7a95e9b279250dad22e2b (patch)
treef4792c68c9f2e47d340d8c8814f2d31d5c9606c5 /index.pl
parent32afee9946595dc615ea1c78ae184a6e13a9722e (diff)
Handle ALL^wmost of the errors!
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl36
1 files changed, 24 insertions, 12 deletions
diff --git a/index.pl b/index.pl
index 2795d7f..b22197e 100644
--- a/index.pl
+++ b/index.pl
@@ -71,19 +71,31 @@ sub get_results_for {
= Travel::Status::DE::IRIS::Stations::get_station($station);
if ( @station_matches == 1 ) {
$station = $station_matches[0][0];
+ my $status = Travel::Status::DE::IRIS->new(
+ station => $station,
+ main_cache => $cache_iris_main,
+ realtime_cache => $cache_iris_rt,
+ %opt
+ );
+ $data = {
+ results => [ $status->results ],
+ errstr => $status->errstr,
+ station_name =>
+ ( $status->station ? $status->station->{name} : $station ),
+ };
+ }
+ elsif ( @station_matches > 1 ) {
+ $data = {
+ results => [],
+ errstr => 'Ambiguous station name',
+ };
+ }
+ else {
+ $data = {
+ results => [],
+ errstr => 'Unknown station name',
+ };
}
-
- my $status = Travel::Status::DE::IRIS->new(
- station => $station,
- main_cache => $cache_iris_main,
- realtime_cache => $cache_iris_rt,
- %opt
- );
- $data = {
- results => [ $status->results ],
- errstr => $status->errstr,
- station_name => $status->station->{name},
- };
}
elsif ( $backend eq 'ris' ) {
$data = $cache_hafas->thaw($cache_str);