diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2016-01-23 10:52:30 +0100 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2016-01-23 10:52:30 +0100 | 
| commit | 358dd887d7e3f5a7ada7a95e9b279250dad22e2b (patch) | |
| tree | f4792c68c9f2e47d340d8c8814f2d31d5c9606c5 | |
| parent | 32afee9946595dc615ea1c78ae184a6e13a9722e (diff) | |
Handle ALL^wmost of the errors!
| -rw-r--r-- | index.pl | 36 | 
1 files changed, 24 insertions, 12 deletions
@@ -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);  | 
